<template>
  <div
    v-if="dialogTableVisible1"
    :fullscreen="false"
    :modal="false"
    :show-close="false"
    :width="screenWidth + 20 + 'px'"
    :append-to-body="true"
    style="
      position: absolute;
      left: 6rem;
      margin-top: 42px;
      z-index: 10;
      background-color: white;
    "
    :close-on-click-modal="false"
  >
    <el-container>
      <el-header height="35px" :style="{ 'border-bottom': '1px solid #ccc' }">
        <!-- 头部按钮 -->
        <div
          :style="{
            height: '35px',
            width: '100%',
          }"
        >
          <div style="position: absolute; right: 15px">
            <!-- <el-button @click="flushed" type="primary"> 刷新</el-button> -->
            <!-- <el-button @click="addRow" type="primary">增行</el-button> -->
            <!-- <el-button @click="deleteSelectedRows" type="danger">删除</el-button> -->
            <el-button
              type="primary"
              @click="getAllData(ruleFormRef)"
              v-if="showInsertButton"
              >保存</el-button
            >
            <el-button
              type="primary"
              @click="updateMaterialsFixed(ruleFormRef)"
              v-if="!showInsertButton"
              >保存</el-button
            >

            <el-button @click="OFFdialogTableVisible" type="danger">关闭</el-button>
          </div>
        </div>
        <!-- <el-row type="flex" justify="end" style="background-color: rgb(211, 227, 253)">
        <div>
          <el-button @click="inseartAdminUser" type="success"> 新增</el-button>
        </div>
      </el-row> -->
      </el-header>

      <el-container>
        <el-aside
          :width="360 + 'px'"
          :style="{
            'z-index': '1',
            'min-width': '360px',
            height: dynamicHeight + 'px',
            'max-height': dynamicHeight + 'px',
            'overflow-y': 'auto',
            'border-right': '1px solid #ccc',
          }"
        >
          <el-table
            border
            stripe
            ref="tableEle"
            :data="tableEle3"
            :row-key="(row: any) => row.id"
            :header-cell-style="headerCellStyle3"
            @selection-change="headehandleSelectionChange3"
            :row-style="rowState"
            :cell-style="cellStyle3"
            @row-click="RowClick3"
          >
            <el-table-column type="expand">
              <!-- 子表 -->
              <el-table :data="tableEle4" border stripe :row-key="(row: any) => row.cid">
                <!-- <el-table-column prop="cid" label="ID" width="100" /> -->
                <!-- <el-table-column prop="componentID" label="零件ID" width="80" /> -->
                <el-table-column prop="level" label="层级" width="40" />
                <el-table-column prop="componentName" label="零件名称" width="100" />
                <!-- <el-table-column prop="parentID" label="上级ID" /> -->

                <el-table-column prop="quantity" width="40" label="数量" />
                <el-table-column label="按钮" fixed="right" align="center" width="190">
                  <template #default="scope">
                    <el-button size="small" @click="handleEdit4(scope.$index, scope.row)"
                      >修改</el-button
                    >
                    <el-button size="small" @click="handleEdit3(scope.$index, scope.row)"
                      >+下级</el-button
                    >
                    <el-button size="small" @click="handleEdit2(scope.$index, scope.row)"
                      >+同级</el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
            </el-table-column>
            <!-- <el-table-column type="selection" width="40" align="center" /> -->
            <!-- <el-table-column prop="id" label="id" />
            <el-table-column prop="businessTypeID" label="业务类型ID" /> -->
            <el-table-column
              prop="structureCode"
              label="结构编码"
              align="center"
              width="130"
            />
            <el-table-column
              prop="structureName"
              label="结构名称"
              align="center"
              width="140"
            />
            <el-table-column prop="version" label="版本" align="center" width="40" />
            <!-- <el-table-column label="按钮" fixed="right" align="center" width="100">
              <template #default="scope">
                <el-button size="small" @click="handleEdit1(scope.$index, scope.row)"
                  >增加下级节点</el-button
                >
              </template>
            </el-table-column> -->
          </el-table>
        </el-aside>
        <el-container>
          <el-header height="43px" :style="{ 'border-bottom': '1px solid #ccc' }">
            <el-scrollbar class="scr">
              <div class="scrollbar-flex-content">
                <div class="scrollbar-demo-item">
                  <el-form
                    ref="ruleFormRef"
                    status-icon
                    :rules="rules"
                    :model="formMainTable"
                    :inline="true"
                  >
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px"
                        >设备结构ID</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.id"
                        clearable
                        disabled
                        placeholder="自动生成"
                      />
                    </el-form-item> -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        结构编码</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.structureCode"
                        clearable
                        disabled
                        placeholder="自动生成"
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0" prop="parentID">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>业务类型</label
                      >
                      <el-cascader
                        style="width: 180px; height: 30px"
                        v-model="parentIDValue"
                        :options="parentIDOptions"
                        :props="props"
                        @change="handleChange"
                        clearable
                        :show-all-levels="false"
                        :disabled="isDiable"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>结构名称</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.structureName"
                        clearable
                        :disabled="isDiable"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px"
                        >版本状态</label
                      >
                      <el-switch
                        v-model="formMainTable.versionStatus"
                        :disabled="isDiable"
                        style="
                          --el-switch-on-color: #13ce66;
                          --el-switch-off-color: #ff4949;
                        "
                      />
                    </el-form-item>
                    <!-- description -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        说明</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.description"
                        clearable
                        :disabled="isDiable"
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        版本</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.version"
                        clearable
                        disabled
                        placeholder="自动生成"
                      />
                    </el-form-item>
                  </el-form>
                </div>
              </div>
            </el-scrollbar>
          </el-header>
          <el-container>
            <el-main :style="{ width: 400 + 'px', padding: '2px 2px 0 2px' }">
              <div>
                <el-scrollbar :style="{ height: dynamicHeight - 41 + 'px' }">
                  <el-form
                    ref="ruleFormRef"
                    status-icon
                    :rules="rules"
                    :model="formMainTable"
                    :inline="true"
                  >
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        ID</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.cID"
                        clearable
                        disabled
                        placeholder="自动生成"
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        主表ID</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.M0ID"
                        clearable
                        disabled
                        placeholder="自动生成"
                      />
                    </el-form-item> -->
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        父级ID</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.parentID"
                        clearable
                        disabled
                      />
                    </el-form-item> -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        级别</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.level"
                        clearable
                        disabled
                      />
                    </el-form-item>
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        零件ID</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.componentID"
                        @click="openEmployeeJob2()"
                        :readonly="true"
                        clearable
                      />
                    </el-form-item> -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        零件名称</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.componentName"
                        @click="openEmployeeJob2()"
                        :readonly="true"
                        clearable
                      />
                    </el-form-item>
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        类别ID</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.categoryID"
                        clearable
                        :readonly="true"
                        @click="openEmployeeJob()"
                      />
                    </el-form-item> -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        类别名称</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.categoryName"
                        clearable
                        :readonly="true"
                        @click="openEmployeeJob()"
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0; display: block">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        是否分上下
                      </label>
                      <el-select
                        @change="clickOrganizationSelect()"
                        v-model="formMainTable.isSplit"
                        style="width: 110px"
                      >
                        <el-option label="是" value="1"></el-option>
                        <el-option label="否" value="0"></el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        上数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.upperCount"
                        :disabled="isDisableduplo"
                        @blur="handleInput('upperCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        下数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.lowerCount"
                        :disabled="isDisableduplo"
                        @blur="handleInput('lowerCount')"
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0; display: block">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        是否分左右
                      </label>
                      <el-select
                        @change="clickOrganizationSelect()"
                        v-model="formMainTable.isSplitLeftRight"
                        style="width: 110px"
                      >
                        <el-option label="是" value="1"></el-option>
                        <el-option label="否" value="0"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        左数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.leftCount"
                        :disabled="isDisabledleri"
                        @blur="handleInput('leftCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        右数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.rightCount"
                        :disabled="isDisabledleri"
                        @blur="handleInput('rightCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        上左数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.upperLeftCount"
                        :disabled="isDisableduploleri"
                        @blur="handleInput('upperLeftCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        上右数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.upperRightCount"
                        :disabled="isDisableduploleri"
                        @blur="handleInput('upperRightCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        下左数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.lowerLeftCount"
                        :disabled="isDisableduploleri"
                        @blur="handleInput('lowerLeftCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        下右数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.lowerRightCount"
                        :disabled="isDisableduploleri"
                        @blur="handleInput('lowerRightCount')"
                      />
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        数量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.quantity"
                        clearable
                        :disabled="isDisabledquantity"
                        @blur="handleInput('quantity')"
                      />
                      <el-form-item class="labs" style="margin-right: 0">
                        <label class="lab" style="width: 80px; padding-right: 5px">
                          单位</label
                        >
                        <el-select
                          v-model="formMainTable.measurementUnit"
                          @change="handleMeasurementUnit('quantity')"
                          style="width: 110px"
                        >
                          <el-option label="单件" value="单件"></el-option>
                          <el-option label="组" value="组"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-form-item>
                    <!-- replacementCycleMethod -->
                    <!-- <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        更换方式</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.replacementCycleMethod"
                        clearable
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        周期天数</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.cycleDays"
                        clearable
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        定额产量</label
                      >
                      <el-input
                        style="width: 110px"
                        v-model="formMainTable.replacementCycleDailyOutput"
                        clearable
                        @input="handleInput('replacementCycleDailyOutput')"
                      />
                    </el-form-item> -->
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        是否实体件
                      </label>
                      <el-select
                        v-model="formMainTable.partAttributes"
                        style="width: 110px"
                      >
                        <el-option label="虚拟件" value="0"></el-option>
                        <el-option label="实体件" value="1"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 80px; padding-right: 5px">
                        耗材类别
                      </label>
                      <el-select
                        v-model="formMainTable.consumableCategory"
                        @change="handleConsumableCategory()"
                        style="width: 110px"
                        size="small"
                      >
                        <el-option label="辊轴类" value="0"></el-option>
                        <el-option label="刀具类" value="1"></el-option>
                        <el-option label="隔套类" value="2"></el-option>
                        <el-option label="辊箱" value="3"></el-option>
                        <el-option label="刀轴" value="4"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-form>
                  <div style="margin: 10px; display: block">
                    <el-button
                      type="primary"
                      @click="getAllData1(ruleFormRef)"
                      v-if="showInsertButton1"
                      >保存</el-button
                    >
                    <el-button
                      type="primary"
                      @click="updateMaterialsFixed1(ruleFormRef)"
                      v-if="!showInsertButton1"
                      >保存</el-button
                    >
                    <el-button
                      @click="deleteChild(ruleFormRef)"
                      v-if="!showInsertButton1"
                      type="danger"
                      >删除</el-button
                    >
                  </div>
                </el-scrollbar>
              </div>
            </el-main>
            <el-aside
              :width="pageWidth - 856 + 'px'"
              :style="{ 'border-left': '1px solid #ccc' }"
            >
              <el-scrollbar :style="{ height: dynamicHeight - 39 + 'px' }">
                <div>
                  <el-collapse v-model="activeNames" @change="handleChange1">
                    <el-collapse-item title="标准设置" name="1">
                      <template #title>
                        <div class="custom-collapse-title">标准设置</div>
                      </template>
                      <div>
                        <el-scrollbar>
                          <el-table
                            ref="multipleTableRef3"
                            :data="tableData3"
                            stripe
                            border
                            :row-style="{ height: '20px' }"
                            style="width: 100%"
                            :cell-style="cellStyle1"
                            @selection-change="handleSelectionChange3"
                            :header-cell-style="headerCellStyle1"
                          >
                            <el-table-column type="selection" width="55" align="center" />
                            <el-table-column label="序号" width="80" align="center">
                              <template #default="{ $index }">
                                <span>{{ $index + 1 }}</span>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column label=" Id" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.id"
                                  disabled
                                  clearable
                                  placeholder="自动生成"
                                  align="center"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column
                              label="按钮"
                              width="140"
                              align="center"
                              fixed="right"
                            >
                              <template #default="{ row, $index }">
                                <el-button
                                  :style="{ height: '25px' }"
                                  type="daprimarynger"
                                  size="mini"
                                  @click="addRowTableData3()"
                                  >增行</el-button
                                >
                                <el-button
                                  :style="{ height: '25px' }"
                                  type="danger"
                                  size="mini"
                                  @click="deleteRow3(row)"
                                  >删除</el-button
                                >
                              </template>
                            </el-table-column>

                            <el-table-column label="颜色" width="80" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.color"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="材质" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <div
                                  style="height: 25px; line-height: 25px; cursor: pointer"
                                  @click="openEmployeeJob3($index)"
                                >
                                  {{ row.material }}
                                </div>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column label="材质" width="180" align="center">
                              <template #header="{ column }">
                                <div @click="openEmployeeJob3()">
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </div>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.material"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column label="规格" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.specification"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="型号" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.model"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="控制方式"
                              width="80"
                              align="center"
                              size="small"
                            >
                              <template #default="{ row, $index }">
                                <el-select
                                  v-model="row.controlMode"
                                  :style="{ height: '25px' }"
                                  size="small"
                                >
                                  <el-option label="单件" value="0" />
                                  <el-option label="组" value="1" />
                                </el-select>
                              </template>
                            </el-table-column>

                            <el-table-column
                              label="外径公差标准"
                              width="100"
                              align="center"
                              v-if="!shouGun"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.outsideDiameterStandard"
                                  @blur="handleTableDate3('outsideDiameterStandard', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="外径公差上限"
                              width="100"
                              align="center"
                              v-if="!shouGun"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minOutsideDiameter"
                                  @blur="handleTableDate3('minOutsideDiameter', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="外径公差下限"
                              width="100"
                              align="center"
                              v-if="!shouGun"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxOutsideDiameter"
                                  @blur="handleTableDate3('maxOutsideDiameter', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>

                            <el-table-column
                              label="工作面长度"
                              width="100"
                              align="center"
                              v-if="!shouGun"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.workingFaceLength"
                                  @blur="handleTableDate3('workingFaceLength', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <!-- <el-table-column
                              label="工作面长度"
                              width="180"
                              align="center"
                              v-if="!shouGun"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.workingFaceLength"
                                  @input="handleTableDate3('workingFaceLength', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column
                              label="是否允许人工报废"
                              width="120"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-select v-model="row.allowManualScrap" size="small">
                                  <el-option label="是" value="1"></el-option>
                                  <el-option label="否" value="0"></el-option>
                                </el-select>
                              </template>
                            </el-table-column>
                            <el-table-column label="重量" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.weight"
                                  @blur="handleTableDate3('weight', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="长度" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.length"
                                  @blur="handleTableDate3('length', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="宽度" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.width"
                                  @blur="handleTableDate3('width', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="高度" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.height"
                                  @blur="handleTableDate3('height', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="直径" width="100" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.diameter"
                                  @blur="handleTableDate3('diameter', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="厚度标准"
                              width="180"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate3('thicknessStandard', row)"
                                  v-model="row.thicknessStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="最小厚度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minThickness"
                                  @blur="handleTableDate3('minThickness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="最大厚度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxThickness"
                                  @blur="handleTableDate3('maxThickness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="内孔标准"
                              width="100"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate3('innerHoleStandard', row)"
                                  v-model="row.innerHoleStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="最小内孔"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minInnerHole"
                                  @blur="handleTableDate3('minInnerHole', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao"
                              label="最大内孔"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxInnerHole"
                                  @blur="handleTableDate3('maxInnerHole', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>

                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="硬度标准"
                              width="100"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate3('hardnessStandard', row)"
                                  v-model="row.hardnessStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="最小硬度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minHardness"
                                  @blur="handleTableDate3('minHardness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="最大硬度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxHardness"
                                  @blur="handleTableDate3('maxHardness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面外径标准"
                              width="100"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="
                                    handleTableDate3(
                                      'workingFaceOuterDiameterStandard',
                                      row
                                    )
                                  "
                                  v-model="row.workingFaceOuterDiameterStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面最小外径"
                              width="110"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minWorkingFaceOuterDiameter"
                                  @blur="
                                    handleTableDate3('minWorkingFaceOuterDiameter', row)
                                  "
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面最大外径"
                              width="110"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxWorkingFaceOuterDiameter"
                                  @blur="
                                    handleTableDate3('maxWorkingFaceOuterDiameter', row)
                                  "
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="非工作面外径标准"
                              width="130"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="
                                    handleTableDate3(
                                      'nonWorkingFaceOuterDiameterStandard',
                                      row
                                    )
                                  "
                                  v-model="row.nonWorkingFaceOuterDiameterStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="非工作面最小外径"
                              width="130"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minNonWorkingFaceOuterDiameter"
                                  @blur="
                                    handleTableDate3(
                                      'minNonWorkingFaceOuterDiameter',
                                      row
                                    )
                                  "
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="非工作面最大外径"
                              width="130"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxNonWorkingFaceOuterDiameter"
                                  @blur="
                                    handleTableDate3(
                                      'maxNonWorkingFaceOuterDiameter',
                                      row
                                    )
                                  "
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="磨削总量"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.grindingTotal"
                                  @blur="handleTableDate3('grindingTotal', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面报废控制方式"
                              width="170"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-select
                                  v-model="row.workingFaceScrapControlMethod"
                                  size="small"
                                >
                                  <el-option label="人工" value="0"></el-option>
                                  <el-option label="自动" value="1"></el-option>
                                  <el-option label="不控制" value="2"></el-option>
                                </el-select>
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面控制参照字段"
                              width="180"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-select
                                  v-model="row.workingFaceControlReferenceField"
                                  size="small"
                                >
                                  <el-option label="工作面最小外径" value="1"></el-option>
                                  <el-option label="——" value="0"></el-option>
                                </el-select>
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面控制逻辑"
                              width="180"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-select
                                  v-model="row.workingFaceControlLogic"
                                  size="small"
                                >
                                  <el-option label="等于" value="0"></el-option>
                                  <el-option label="大于" value="1"></el-option>
                                  <el-option label="小于" value="2"></el-option>
                                  <el-option label="大于等于" value="3"></el-option>
                                  <el-option label="小于等于" value="4"></el-option>
                                </el-select>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column
                              v-if="!shouDao || !shouGun"
                              label="工作面控制逻辑"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.workingFaceControlLogic"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column
                              v-if="!shouGun"
                              label="粗糙度标准"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate3('roughnessStandard', row)"
                                  v-model="row.roughnessStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="最小粗糙度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minRoughness"
                                  @blur="handleTableDate3('minRoughness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="最大粗糙度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxRoughness"
                                  @blur="handleTableDate3('maxRoughness', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="锥度标准"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate3('taperStandard', row)"
                                  v-model="row.taperStandard"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="最小锥度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.minTaper"
                                  @blur="handleTableDate3('minTaper', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="最大锥度"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.maxTaper"
                                  @blur="handleTableDate3('maxTaper', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="锥长"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.taperLength"
                                  @blur="handleTableDate3('taperLength', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGun"
                              label="锥高"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.taperHeight"
                                  @blur="handleTableDate3('taperHeight', row)"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              v-if="!shouGx"
                              label="体积"
                              width="100"
                              align="center"
                            >
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.volume"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                          </el-table>
                        </el-scrollbar>
                      </div>
                    </el-collapse-item>
                    <!-- <el-collapse-item title="控制维度设置" name="2">
                      <template #title>
                        <div class="custom-collapse-title">控制维度设置</div>
                      </template>
                      <div>
                        Operation feedback: enable the users to clearly perceive their
                        operations by style updates and interactive effects;
                      </div>
                      <div>
                        Visual feedback: reflect current state by updating or rearranging
                        elements of the page.
                      </div>
                    </el-collapse-item> -->
                    <el-collapse-item title="物料对照" name="3">
                      <template #title>
                        <div class="custom-collapse-title">物料对照</div>
                      </template>
                      <div>
                        <el-scrollbar>
                          <el-table
                            ref="multipleTableRef2"
                            :data="tableData2"
                            stripe
                            border
                            :row-style="{ height: '20px' }"
                            style="width: 100%"
                            :cell-style="cellStyle1"
                            @selection-change="handleSelectionChange2"
                            :header-cell-style="headerCellStyle1"
                          >
                            <el-table-column type="selection" width="55" align="center" />
                            <el-table-column label="序号" width="80" align="center">
                              <template #default="{ $index }">
                                <span>{{ $index + 1 }}</span>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column label=" Id" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.id"
                                  disabled
                                  clearable
                                  placeholder="自动生成"
                                  align="center"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->

                            <!-- <el-table-column label="零件ID" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.componentID"
                                  disabled
                                  placeholder="自动生成"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <!-- <el-table-column label="物料ID" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  :readonly="true"
                                  v-model="row.materialID"
                                  :style="{ height: '25px' }"
                                  @click="openEmployeeJob1(row)"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column label="物料编码" width="180" align="center">
                              <template #default="{ row, $index }">
                                <div
                                  @click="openEmployeeJob1(row)"
                                  style="cursor: pointer; height: 25px; line-height: 25px"
                                >
                                  {{ row.k3Code }}
                                </div>
                              </template>
                            </el-table-column>
                            <el-table-column label="物料名称" width="180" align="center">
                              <template #default="{ row, $index }">
                                <div
                                  @click="openEmployeeJob1(row)"
                                  style="cursor: pointer; height: 25px; line-height: 25px"
                                >
                                  {{ row.k3Name }}
                                </div>
                              </template>
                            </el-table-column>

                            <!-- <el-table-column label="物料编码" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  :readonly="true"
                                  v-model="row.k3Code"
                                  :style="{ height: '25px' }"
                                  @click="openEmployeeJob1(row)"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="物料名称" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  :readonly="true"
                                  v-model="row.k3Name"
                                  :style="{ height: '25px' }"
                                  @click="openEmployeeJob1(row)"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column label="物料数量" width="180" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  @blur="handleTableDate4('defaultMaterial', row)"
                                  v-model="row.defaultMaterial"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column label="默认物料" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-select v-model="row.materialQuantity" size="small">
                                  <el-option label="是" value="1"></el-option>
                                  <el-option label="否" value="0"></el-option>
                                </el-select>
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="按钮"
                              width="140"
                              align="center"
                              fixed="right"
                            >
                              <template #default="{ row, $index }">
                                <el-button
                                  :style="{ height: '25px' }"
                                  type="daprimarynger"
                                  size="mini"
                                  @click="addRowTableData2()"
                                  >增行</el-button
                                >
                                <el-button
                                  :style="{ height: '25px' }"
                                  type="danger"
                                  size="mini"
                                  @click="deleteRow(row)"
                                  >删除</el-button
                                >
                              </template>
                            </el-table-column>
                          </el-table>
                        </el-scrollbar>
                      </div>
                    </el-collapse-item>
                    <el-collapse-item title="机构组设置" name="4">
                      <template #title>
                        <div class="custom-collapse-title">机构组设置</div>
                      </template>
                      <div>
                        <!-- :style="{ height: childTableHeight - 200 + 'px' }" -->
                        <el-scrollbar>
                          <el-table
                            ref="multipleTableRef"
                            :data="tableData1"
                            stripe
                            border
                            :row-style="{ height: '20px' }"
                            style="width: 100%"
                            :cell-style="cellStyle1"
                            @selection-change="handleSelectionChange1"
                            :header-cell-style="headerCellStyle1"
                          >
                            <el-table-column type="selection" width="55" align="center" />
                            <el-table-column label="序号" width="80" align="center">
                              <template #default="{ $index }">
                                <span>{{ $index + 1 }}</span>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column label=" Id" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.id"
                                  disabled
                                  clearable
                                  placeholder="自动生成"
                                  align="center"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->

                            <!-- <el-table-column label="零件ID" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.componentID"
                                  disabled
                                  placeholder="自动生成"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column label="组号" width="180" align="center">
                              <template #default="{ row, $index }">
                                <div
                                  :style="{
                                    height: '25px',
                                    lineHeight: '25px',
                                    paddingLeft: '10px',
                                  }"
                                >
                                  {{ row.groupNumber ? row.groupNumber : "自动生成" }}
                                </div>
                              </template>
                            </el-table-column>

                            <!-- <el-table-column label="组号" width="180" align="center">
                              <template #default="{ row, $index }">
                                <el-input
                                  disabled
                                  placeholder="自动生成"
                                  v-model="row.groupNumber"
                                  :style="{ height: '25px' }"
                                />
                              </template>
                            </el-table-column> -->
                            <el-table-column label="组内数量" width="180" align="center">
                              <template #header="{ column }">
                                <span>
                                  {{ column.label }}
                                  <span style="color: red; font-weight: 700">*</span>
                                </span>
                              </template>
                              <template #default="{ row, $index }">
                                <el-input
                                  v-model="row.quantityWithinGroup"
                                  :style="{ height: '25px' }"
                                  @input="handTableData1('quantityWithinGroup', row)"
                                />
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="组间是否通用"
                              width="120"
                              align="center"
                            >
                              <template #default="{ row, $index }">
                                <el-switch
                                  v-model="row.universalBetweenGroups"
                                  :style="{ height: '25px' }"
                                  active-value="1"
                                  inactive-value="0"
                                  active-color="#13ce66"
                                  inactive-color="#ff4949"
                                />
                              </template>
                            </el-table-column>
                          </el-table>
                        </el-scrollbar>
                      </div>
                    </el-collapse-item>
                    <!-- <el-collapse-item title="备件周期" name="5">
                      <template #title>
                        <div class="custom-collapse-title">备件周期</div>
                      </template>
                      <div>
                        Decision making: giving advices about operations is acceptable,
                        but do not make decisions for the users;
                      </div>
                      <div>
                        Controlled consequences: users should be granted the freedom to
                        operate, including canceling, aborting or terminating current
                        operation.
                      </div>
                    </el-collapse-item> -->
                  </el-collapse>
                </div>
              </el-scrollbar>
            </el-aside>
          </el-container>
        </el-container>
      </el-container>
    </el-container>
  </div>
  <el-container>
    <el-header height="65px" :style="{ 'border-bottom': '1px solid #ccc' }">
      <!-- 头部按钮 -->
      <el-row type="flex" justify="end" style="background-color: rgb(211, 227, 253)">
        <div>
          <el-button @click="searchButton" type="primary"> 查询</el-button>
          <el-button @click="openInseart" type="success"> 新增</el-button>
          <el-button @click="deleteButton" type="danger"> 删除</el-button>
        </div>
        <!-- <div class="title">需求汇总统计表</div> -->
      </el-row>
      <div
        style="
          margin-left: 6rem;
          height: 30px;

          background: rgb(241, 244, 243);
          margin-bottom: 0;
          position: relative;
          display: flex;
          justify-content: flex-start;
        "
      >
        <el-input
          style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
          v-model="inputName"
          placeholder="结构名称"
        >
          <template #prefix>
            <el-icon class="">
              <search />
            </el-icon>
          </template>
        </el-input>
        <el-input
          style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
          v-model="inputCode"
          placeholder="结构编号"
        >
          <template #prefix>
            <el-icon class="">
              <search />
            </el-icon>
          </template>
        </el-input>
      </div>
    </el-header>
    <el-container>
      <el-container>
        <el-main style="padding: 2px 2px 0 2px; margin-left: 6rem">
          <el-table
            v-loading="loading"
            ref="table"
            :data="tableData"
            border
            stripe
            :cell-style="cellStyle"
            :header-cell-style="headerCellStyle"
            @selection-change="handleSelectionChange"
            @row-dblclick="handleRowClick"
            @row-click="RowClick"
            :row-style="rowState"
            :row-key="(row: any) => row.id"
            :max-height="screenHeight"
            :height="screenHeight"
            :max-width="'300px'"
          >
            <el-table-column fixed type="index" width="80" align="center" />
            <el-table-column fixed type="selection" width="50" align="center" />
            <!-- <el-table-column prop="id" label="设备结构ID" width="120" align="center" /> -->
            <el-table-column
              prop="structureCode"
              label="结构编号"
              width="120"
              align="center"
            />
            <el-table-column
              prop="structureName"
              label="结构名称"
              width="120"
              align="center"
            />
            <!-- <el-table-column
              prop="businessTypeID"
              label="业务类型ID"
              width="120"
              align="center"
            /> -->
            <el-table-column
              prop="businessTypeName"
              label="业务类型名称"
              width="120"
              align="center"
            />
            <el-table-column
              prop="versionStatus"
              label="版本状态"
              width="120"
              align="center"
            />
            <el-table-column prop="description" label="说明" width="200" align="center" />
          </el-table>
        </el-main>
        <el-footer style="height: 20px">
          <div class="demo-pagination-block">
            <el-pagination
              v-model:current-page="page"
              v-model:page-size="limit"
              :page-sizes="[50, 500, 1000, 1500, 2000, 8000]"
              :small="true"
              :background="true"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </el-footer>
      </el-container>
    </el-container>
  </el-container>
  <SearchTableDialog
    ref="sea"
    @row-data="handleRowData"
    @row-datas="handleRowDatas"
  ></SearchTableDialog>
  <SearchTableDialog
    ref="sec"
    @row-data="handleRowData1"
    @row-datas="handleRowDatas1"
  ></SearchTableDialog>
  <SearchTableDialog
    ref="sed"
    @row-data="handleRowData2"
    @row-datas="handleRowDatas2"
  ></SearchTableDialog>
  <!-- 材质 -->
  <SearchTableDialog
    ref="seb"
    @row-data="handleRowData3"
    @row-datas="handleRowDatas3"
  ></SearchTableDialog>
</template>
<script setup lang="ts">
import {
  ref,
  watch,
  reactive,
  onMounted,
  onBeforeMount,
  computed,
  nextTick,
  onUnmounted,
  toRefs,
} from "vue";
import { Delete, Edit, Search, Share, Upload, Calendar } from "@element-plus/icons-vue";
import {
  ElButton,
  ElDialog,
  dialogEmits,
  ElMessage,
  ElTable,
  TableColumnCtx,
  ElMessageBox,
} from "element-plus";
import type { FormInstance, FormRules } from "element-plus";
import { formatNumberToCurrency } from "@/utils/formatUtils";

import { CircleCloseFilled } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import axios from "../../axios/axiosInstance.ts";
import Cookies from "js-cookie";
import { format } from "date-fns";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
// crud封装组件
import * as crud from "../../components/utils/crud.ts";
import SearchTableDialog from "@/components/dialogs/SearchTableDialog.vue";
import * as notifications from "../../components/utils/notification.ts";
// 时间
// 获取当前时间
const getCurrentFormattedDateTime = () => {
  const currentDateTime = new Date();

  // 格式化当前时间
  const formattedDateTime = currentDateTime.toLocaleString("zh-CN", {
    year: "numeric",
    month: "2-digit",
    day: "2-digit",
    hour: "2-digit",
    minute: "2-digit",
    second: "2-digit",
  });
  // const formattedDateTime = format(currentDateTime, "YYYY-MM-dd HH:mm:ss");

  return formattedDateTime;
};
// 获取年月日
const getCurrentFormattedDate = () => {
  const currentDateTime = new Date();

  // 格式化当前时间，只获取年月日
  const formattedDate = currentDateTime.toLocaleString("zh-CN", {
    year: "numeric",
    month: "2-digit",
    day: "2-digit",
  });

  return formattedDate;
};
// 权限控制
const searchButtonPermissionsA = ref(false);
const menuId = ref(0);
const buttonVariables = {
  searchButtonPermissionsA,
};
const selectPermissionsButton = () => {
  const userName = Cookies.get("userName");
  axios({
    url: "/select/Permissions/Button",
    method: "post",
    data: {
      userName: userName,
      menuId: menuId.value,
    },
  }).then((res) => {
    res.data.forEach((button) => {
      const buttonName = button.buttonName;
      if (buttonVariables.hasOwnProperty(buttonName)) {
        buttonVariables[buttonName].value = true;
      }
    });
  });
};
selectPermissionsButton();
//权限结束
const tableData = ref([]);
const dialogTableVisible1 = ref(false);
const loading = ref(false);
const page = ref(1);
const limit = ref(50);
const total = ref(50);
const inputName = ref("");
const inputCode = ref("");
const selectBusinessDate = computed(() => ({
  page: page.value,
  limit: limit.value,
  structureName: inputName.value,
  structureCode: inputCode.value,
}));
const handleSizeChange = (val: number) => {
  selectBusinessType();
};
const handleCurrentChange = (val: number) => {
  selectBusinessType();
};
const searchButton = () => {
  selectBusinessType();
};
const selectBusinessType = async () => {
  loading.value = true;
  try {
    const res = await crud.fetchData(
      "/Equ/select/EquipmentStructure",
      "post",
      selectBusinessDate.value
    );
    if (res.length == 0) {
      total.value = 0;
      tableData.value = [];
      loading.value = false;
      return;
    }
    const definitionsList = res;
    total.value = definitionsList[0].total;
    loading.value = false;
    console.log(res);
    tableData.value = definitionsList.map((item: any) => ({
      versionStatus: item.versionStatus === 0 ? "未启用" : "启用",
      businessTypeID: item.businessTypeID,
      businessTypeName: item.businessTypeName,
      description: item.description,
      id: item.id,
      majorVersion: item.majorVersion,
      minorVersion: item.minorVersion,
      revisionVersion: item.revisionVersion,
      structureCode: item.structureCode,
      structureName: item.structureName,
      version: item.version,
      versionStatus: item.versionStatus,
    }));
  } catch (error) {
    loading.value = false;
    console.error("请求失败:", error);
  }
};
selectBusinessType();
// 表格
const headerCellStyle = {
  // E9E9E7
  borderColor: "#B9C9C7",
  backgroundColor: "#F2F4FA", // 表头背景颜色
  fontWeight: "bold", // 表头文字粗细
  color: "#1F2129",
  // padding: "0 0 0 30px",
};
const rowState = (arg) => {
  return {
    height: "20px", // 设置合适的行高值
    fontSize: "12px", // 设置合适的字体大小值
    // color: "black",
  };
};
const RowClick = (row, selection) => {
  table.value.toggleRowSelection(row);
};
const selectedRows = ref([]);
const table = ref();

const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
  if (selectedRows.value.find((selectedRow) => selectedRow.id === row.id)) {
    return {
      backgroundColor: "#DFF0DB !important",
      borderColor: "#B9C9C7",
      padding: "4px",
    };
  } else {
    return { borderColor: "#B9C9C7", padding: "4px", margin: 0 };
  }
};
const handleSelectionChange = (selection: any) => {
  selectedRows.value = selection;
};
const screenHeight = ref(null);
const screenWidth = ref(null);
const childTableHeight = ref(null);

const getScreenHeight = () => {
  childTableHeight.value = window.innerHeight;
  screenHeight.value = window.innerHeight - 146;
  screenWidth.value = window.innerWidth;
};
getScreenHeight();
const requestDataAsid = computed(() => ({
  deleteIdList: selectedRows.value,
}));

const deleteButton = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认删除", "success");
    if (result) {
      if (selectedRows.value.length === 0) {
        notifications.showMessage("请至少选择一行进行操作", "error");
        return;
      }

      const res = await crud.sendRequest(
        "/Equ/delete/EquipmentStructure/ALL",
        "post",
        requestDataAsid.value
      );
      selectBusinessType();
    }
  } catch (error) {
    console.error("请求失败:", error);
  }
};
// 折叠
const activeNames = ref(["1", "2", "3", "4", "5"]);
const handleChange1 = (val: string[]) => {
  console.log(val);
  //   activeNames.value = ["1", "2", "3", "4"];
};
// 业务类型回显
const asideListData = ref([]);
const asideList = async () => {
  try {
    const res = await crud.fetchData(
      "/BusinessType/select/BusinessType/All/Auto1",
      "post",
      requestData.value
    );
    asideListData.value = res; // 将结果赋值给 ref
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const getParentIds = (nodeId) => {
  const parentIds = [];
  let currentNode = asideListData.value.find((node) => node.id === nodeId);
  while (currentNode && currentNode.parentID !== null) {
    parentIds.push(currentNode.id);
    currentNode = asideListData.value.find((node) => node.id === currentNode.parentID);
  }
  return parentIds.reverse();
};

// 修改弹窗
const handleRowClick = async (row, selection) => {
  // 业务类型回显
  await asideList();

  for (let i = 0; i < asideListData.value.length; i++) {
    if (asideListData.value[i].id == row.businessTypeID) {
      // 当前节点的父级内容
      var matchedNode = asideListData.value[i];
      break;
    }
  }
  if (matchedNode == null) {
    parentIDValue.value[0] = 1;
    formAsid.value.parentID = 1;
  } else {
    const ids = getParentIds(row.businessTypeID);
    console.log(ids);
    parentIDValue.value = ids;
  }
  // 业务类型回显结束
  dialogTableVisible1.value = true;
  showInsertButton.value = false;
  showInsertButton1.value = true;
  isDiable.value = false;
  tableData1.value = [];
  tableData3.value = [];
  for (let i = 0; i < 5; i++) {
    tableData3.value.push({
      ...defaultRowData3,
    });
  }
  for (let i = 0; i < 5; i++) {
    tableData2.value.push({
      ...defaultRowData2,
    });
  }
  try {
    const res = await crud.fetchData("/Equ/select/All/Main", "post", {
      ID: row.id,
    });
    console.log(res);
    formMainTable.value.id = res[0].id;
    formMainTable.value.M0ID = res[0].id;
    formMainTable.value.businessTypeID = res[0].businessTypeID;
    formMainTable.value.businessTypeName = res[0].businessTypeName;
    formMainTable.value.structureCode = res[0].structureCode;
    formMainTable.value.structureName = res[0].structureName;
    formMainTable.value.versionStatus = res[0].versionStatus == 1 ? true : false;
    formMainTable.value.version = res[0].version;
    formMainTable.value.description = res[0].description;
    tableEle3.value = res;
    console.log(res);
    tableEle4.value = res[0].eqmList;
  } catch (error) {
    console.error("请求失败:", error);
  }
};
// 新增页面展示
const openInseart = async () => {
  dialogTableVisible1.value = true;
  isDiable.value = false;
  showInsertButton.value = true;
  showInsertButton1.value = true;
  tableData3.value = [];
  tableEle3.value = [];
  tableEle4.value = [];
  for (let i = 0; i < 5; i++) {
    tableData3.value.push({
      ...defaultRowData3,
    });
  }
  for (let i = 0; i < 5; i++) {
    tableData2.value.push({
      ...defaultRowData2,
    });
  }
};

interface RuleForm {
  code: string;
  id: string;
  name: string;
  description: string;
  status: boolean;
  creationTime: string;
}
const form = reactive<RuleForm>({
  code: "",
  id: "",
  name: "",
  description: "",
  status: true,
  creationTime: "",
});
const ruleFormRef = ref<FormInstance>();
const rules = reactive<FormRules<RuleForm>>({
  // name: [{ message: "请输入班组名称", trigger: "blur"  }],
});
// 子表展示
const cellStyle1 = ({ row, column, rowIndex, columnIndex }) => {
  return { borderColor: "#B9C9C7", padding: "0px", margin: 0 };
};
const showInsertButton = ref(true);
const showInsertButton1 = ref(true);
const multipleTableRef = ref();
const multipleTableRef2 = ref();
const multipleTableRef3 = ref();
const handleSelectionChange1 = (val: any[]) => {
  console.log("Selected Rows:", val);
};
const defaultRowData2 = {
  id: "",
  componentID: "", //零件ID
  materialID: "", //物料ID
  defaultMaterial: "", //默认物料
  materialQuantity: "1", //物料数量
  k3Code: "", //物料编码
  k3Name: "", //物料名称
};
const defaultRowData3 = {
  autoId: "", // 自增ID
  id: "", // 主键ID
  informationType: "", // 信息类型
  equipmentStructureId: "", // 设备结构ID
  componentId: "", // 业务项目ID（零件ID）
  consumableCategory: "", // 耗材类别
  color: "", // 颜色
  material: "", // 材质
  specification: "", // 规格
  model: "", // 型号
  controlMode: "0", //控制方式
  workingFaceLength: "", // 工作面长度
  allowManualScrap: "1", // 是否允许人工报废
  weight: "", // 重量
  length: "", // 长度
  width: "", // 宽度
  height: "", // 高度
  diameter: "", // 直径
  thicknessStandard: "", // 厚度标准
  minThickness: "", // 最小厚度
  maxThickness: "", // 最大厚度
  innerHoleStandard: "", // 内孔标准
  minInnerHole: "", // 最小内孔
  maxInnerHole: "", // 最大内孔
  hardnessStandard: "", // 硬度标准
  minHardness: "", // 最小硬度
  maxHardness: "", // 最大硬度
  workingFaceOuterDiameterStandard: "", // 工作面外径标准
  minWorkingFaceOuterDiameter: "", // 工作面最小外径
  maxWorkingFaceOuterDiameter: "", // 工作面最大外径
  nonWorkingFaceOuterDiameterStandard: "", // 非工作面外径标准
  minNonWorkingFaceOuterDiameter: "", // 非工作面最小外径
  maxNonWorkingFaceOuterDiameter: "", // 非工作面最大外径
  grindingTotal: "", // 磨削总量
  workingFaceScrapControlMethod: "0", // 工作面报废控制方式
  workingFaceControlReferenceField: "1", // 工作面控制参照字段
  workingFaceControlLogic: "0", // 工作面控制逻辑
  roughnessStandard: "", // 粗糙度标准
  minRoughness: "", // 最小粗糙度
  maxRoughness: "", // 最大粗糙度
  taperStandard: "", // 锥度标准
  minTaper: "", // 最小锥度
  maxTaper: "", // 最大锥度
  taperLength: "", // 锥长
  taperHeight: "", // 锥高
  volume: "", //体积
  outsideDiameterStandard: "", //外径公差标准
  minOutsideDiameter: "", //外径公差上限
  maxOutsideDiameter: "", //外径公差下限
};
const tableData3 = ref([
  //   {
  //     ...defaultRowData3,
  //   },
  // More data...
]);
const tableData2 = ref([]);
const defaultRowData = {
  id: "",
  componentID: "",
  groupNumber: "",
  quantityWithinGroup: "",
  universalBetweenGroups: "1",
};

const tableData1 = ref([
  //   {
  //     ...defaultRowData,
  //   },
  // More data...
]);
const addRowTableData3 = () => {
  //   for (let i = 0; i < 20; i++) {
  //     }
  tableData3.value.push({
    ...defaultRowData3,
  });
};

const addRowTableData2 = () => {
  //   for (let i = 0; i < 20; i++) {
  //     }
  tableData2.value.push({
    ...defaultRowData2,
  });
};
const groupNumberLabel = ref("组号");
const groupNumberLabel1 = ref("组内数量");
const groupNumberDisabled = ref(true);
const handTableData1 = (prop, row) => {
  const index = tableData1.value.indexOf(row);

  if (row[prop] === "") {
    row[prop] = "";
  } else {
    row[prop] = row[prop].replace(/\D/g, "");
  }
};
const OFFdialogTableVisible = () => {
  dialogTableVisible1.value = false;
  selectBusinessType();
  flushed();
};
const flushed = () => {
  parentIDValue.value = "";
  formMainTable.value.id = "";
  formMainTable.value.businessTypeID = "";
  formMainTable.value.businessTypeName = "";
  formMainTable.value.structureCode = "";
  formMainTable.value.structureName = "";
  formMainTable.value.versionStatus = true;
  formMainTable.value.version = "";
  formMainTable.value.majorVersion = "";
  formMainTable.value.minorVersion = "";
  formMainTable.value.revisionVersion = "";
  formMainTable.value.description = "";
  formMainTable.value.cID = "";
  formMainTable.value.M0ID = "";
  formMainTable.value.componentID = "";
  formMainTable.value.componentName = "";
  formMainTable.value.categoryName = "";
  formMainTable.value.categoryID = "";
  formMainTable.value.parentID = 0;
  formMainTable.value.level = 0;
  formMainTable.value.isLeaf = "";
  formMainTable.value.isSplit = "0";
  formMainTable.value.isSplitLeftRight = "0";
  formMainTable.value.measurementUnit = "单件";
  formMainTable.value.quantity = 0;
  formMainTable.value.replacementCycleMethod = "";
  formMainTable.value.cycleDays = "";
  formMainTable.value.replacementCycleDailyOutput = 0;
  formMainTable.value.partAttributes = "1";
  formMainTable.value.upperCount = 0;
  formMainTable.value.lowerCount = 0;
  formMainTable.value.leftCount = 0;
  formMainTable.value.rightCount = 0;
  formMainTable.value.upperLeftCount = 0;
  formMainTable.value.upperRightCount = 0;
  formMainTable.value.lowerLeftCount = 0;
  formMainTable.value.lowerRightCount = 0;
  formMainTable.value.upperUnit = "单件";
  formMainTable.value.lowerUnit = "单件";
  formMainTable.value.leftUnit = "单件";
  formMainTable.value.rightUnit = "单件";
  formMainTable.value.upperLeftUnit = "单件";
  formMainTable.value.upperRightUnit = "单件";
  formMainTable.value.lowerLefUnit = "单件";
  formMainTable.value.lowerRighUnit = "单件";
  formMainTable.value.componentCategoryId = "";
  formMainTable.value.componentCategoryCode = "";
  formMainTable.value.componentCategoryName = "";
  formMainTable.value.componentCategoryDescription = "0";
  formMainTable.value.consumableCategory = "0";
  tableData1.value = [];
  tableData2.value = [];
  tableData3.value = [];

  for (let i = 0; i < 5; i++) {
    tableData3.value.push({
      ...defaultRowData3,
    });
  }
};
const addRow = () => {
  tableData1.value.push({ ...defaultRowData });
};
const requestFormTable = computed(() => {
  //   const tableDate2Lsit = tableData2.value.filter((item) => item.materialID !== "");
  const tableDate2Lsit = tableData2.value
    .filter((item) => item.materialID !== "")
    .map((item) => {
      return {
        ...item,
        materialQuantity: 1,
      };
    });
  const tableDate1Lsit = tableData1.value.filter(
    (item) => item.quantityWithinGroup !== ""
  );
  const tableDate3Lsit = tableData3.value.filter((item) => item.weight !== "");
  return {
    formMainTable: formMainTable.value,
    //  childList: usefulDataArray,
    tableDate2Lsit: tableDate2Lsit,
    tableDate1Lsit: tableDate1Lsit,
    tableDate3Lsit: tableDate3Lsit,
    ID: formMainTable.value.id,
    version: formMainTable.value.version,
    cID: formMainTable.value.cID,
    businessTypeID: formMainTable.value.businessTypeID,
    quantity: formMainTable.value.quantity,
    measurementUnit: formMainTable.value.measurementUnit,
    structureName: formMainTable.value.structureName,
    description: formMainTable.value.description,
    versionStatus: formMainTable.value.versionStatus == true ? 1 : 0,
    componentID: formMainTable.value.componentID,
    categoryID: formMainTable.value.categoryID,
    isSplit: formMainTable.value.isSplit,
    isSplitLeftRight: formMainTable.value.isSplitLeftRight,
    replacementCycleMethod: formMainTable.value.replacementCycleMethod,
    cycleDays: formMainTable.value.cycleDays,
    replacementCycleDailyOutput: formMainTable.value.replacementCycleDailyOutput,
    partAttributes: formMainTable.value.partAttributes,
    upperCount: formMainTable.value.upperCount,
    lowerCount: formMainTable.value.lowerCount,
    leftCount: formMainTable.value.leftCount,
    rightCount: formMainTable.value.rightCount,
    upperLeftCount: formMainTable.value.upperLeftCount,
    upperRightCount: formMainTable.value.upperRightCount,
    lowerLeftCount: formMainTable.value.lowerLeftCount,
    lowerRightCount: formMainTable.value.lowerRightCount,
    componentCategoryID: formMainTable.value.componentCategoryID,
    componentCategoryName: formMainTable.value.componentCategoryName,
    componentCategoryCode: formMainTable.value.componentCategoryCode,
    componentCategoryDescription: formMainTable.value.componentCategoryDescription,
    // 零件参数表：
    consumableCategory: formMainTable.value.consumableCategory,
  };
});

const updateMaterialsFixed = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认保存", "success");
    if (!result) {
      return;
    }
    if (formMainTable.value.businessTypeID == "") {
      notifications.showMessage("请输入业务类型", "error");
      return;
    }
    if (formMainTable.value.structureName == "") {
      notifications.showMessage("请输入结构名称", "error");
      return;
    }

    console.log(requestFormTable.value);
    //"/Equ/add/EquipmentStructure",
    const res = await crud.fetchData(
      "/Equ/update/Equipment/EquipmentStructure/Main",
      "post",
      requestFormTable.value
    );
    showInsertButton.value = false;
    isDiable.value = true;
    showInsertButton1.value = true;
    //  tableEle3.value = res;
    //  formMainTable.value.M0ID = res[0].id;
    //  formMainTable.value.id = res[0].id;
    //  formMainTable.value.structureCode = res[0].structureCode;
    //  formMainTable.value.version = res[0].version;
  } catch (error) {
    console.error("请求失败:", error);
  }
};

const getAllData = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认保存", "success");
    if (!result) {
      return;
    }
    if (formMainTable.value.businessTypeID == "") {
      notifications.showMessage("请输入业务类型", "error");
      return;
    }
    if (formMainTable.value.structureName == "") {
      notifications.showMessage("请输入结构名称", "error");
      return;
    }

    console.log(requestFormTable.value);
    //"/Equ/add/EquipmentStructure",
    const res = await crud.fetchData(
      "/Equ/select/EquipmentStructureID",
      "post",
      requestFormTable.value
    );
    showInsertButton.value = false;
    isDiable.value = true;
    showInsertButton1.value = true;
    tableEle3.value = res;
    formMainTable.value.M0ID = res[0].id;
    formMainTable.value.id = res[0].id;
    formMainTable.value.structureCode = res[0].structureCode;
    formMainTable.value.version = res[0].version;
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const isDiable = ref(false);

const deleteChild = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认删除", "success");
    if (!result) {
      return;
    }
    console.log(requestFormTable.value);
    const res = await crud.sendRequest(
      "/Equ/delete/EquipmentStructure/ChileChild",
      "post",
      requestFormTable.value
    );

    isDiable.value = true;
    showInsertButton.value = false;
    showInsertButton1.value = true;
    isDiable.value = true;
    formMainTable.value.cID = "";
    formMainTable.value.componentID = "";
    formMainTable.value.componentName = "";
    formMainTable.value.categoryName = "";
    formMainTable.value.categoryID = "";
    formMainTable.value.parentID = 0;
    formMainTable.value.level = 0;
    formMainTable.value.isLeaf = "";
    formMainTable.value.isSplit = "0";
    formMainTable.value.isSplitLeftRight = "0";
    formMainTable.value.measurementUnit = "单件";
    formMainTable.value.quantity = 0;
    formMainTable.value.replacementCycleMethod = "";
    formMainTable.value.cycleDays = "";
    formMainTable.value.replacementCycleDailyOutput = 0;
    formMainTable.value.partAttributes = "1";
    formMainTable.value.upperCount = 0;
    formMainTable.value.lowerCount = 0;
    formMainTable.value.leftCount = 0;
    formMainTable.value.rightCount = 0;
    formMainTable.value.upperLeftCount = 0;
    formMainTable.value.upperRightCount = 0;
    formMainTable.value.lowerLeftCount = 0;
    formMainTable.value.lowerRightCount = 0;
    formMainTable.value.upperUnit = "单件";
    formMainTable.value.lowerUnit = "单件";
    formMainTable.value.leftUnit = "单件";
    formMainTable.value.rightUnit = "单件";
    formMainTable.value.upperLeftUnit = "单件";
    formMainTable.value.upperRightUnit = "单件";
    formMainTable.value.lowerLefUnit = "单件";
    formMainTable.value.lowerRighUnit = "单件";
    formMainTable.value.componentCategoryId = "";
    formMainTable.value.componentCategoryCode = "";
    formMainTable.value.componentCategoryName = "";
    formMainTable.value.componentCategoryDescription = "0";
    formMainTable.value.consumableCategory = "0";
    tableData1.value = [];
    tableData2.value = [];
    for (let i = 0; i < 5; i++) {
      tableData2.value.push({
        ...defaultRowData2,
      });
    }
    tableData3.value = [];
    for (let i = 0; i < 5; i++) {
      tableData3.value.push({
        ...defaultRowData3,
      });
    }
    await updateFormData(formMainTable.value.M0ID);
    //  await fetchSecondAsyncOperation();
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const updateFormData = async (id) => {
  try {
    const res = await crud.fetchData("/Equ/select/All/Main", "post", {
      ID: id,
    });
    console.log(res);
    formMainTable.value.id = res[0].id;
    // 更新其他表单数据...

    // 更新表格数据
    //  console.log(res[0].eqmList);
    tableEle4.value = res[0].eqmList;
  } catch (error) {
    console.error("请求失败:", error);
  }
};

const updateMaterialsFixed1 = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认保存", "success");
    if (!result) {
      return;
    }
    //  if (!formMainTable.value.M0ID) {
    //    notifications.showMessage("请先保存主表内容", "error");
    //    return;
    //  }
    //  if (formMainTable.value.quantity === 0) {
    //    notifications.showMessage("数量不为0", "error");
    //    return;
    //  }
    if (formMainTable.value.componentName === "") {
      notifications.showMessage("请选择零件", "error");
      return;
    }
    if (formMainTable.value.categoryName === "") {
      notifications.showMessage("请选择类别", "error");
      return;
    }
    //  if (formMainTable.value.replacementCycleMethod === "") {
    //    notifications.showMessage("请输入更换方式", "error");
    //    return;
    //  }
    //  if (formMainTable.value.cycleDays === "") {
    //    notifications.showMessage("请输入周期天数", "error");
    //    return;
    //  }
    //  if (formMainTable.value.replacementCycleDailyOutput === 0) {
    //    notifications.showMessage("定额产量不能为0", "error");
    //    return;
    //  }

    //  if (requestFormTable.value.tableDate2Lsit.length == 0) {
    //    notifications.showMessage("物料对照表不能为空", "error");
    //    return;
    //  }
    for (let i = 0; i < requestFormTable.value.tableDate2Lsit.length; i++) {
      if (requestFormTable.value.tableDate2Lsit[i].k3Code != "") {
        if (
          //  requestFormTable.value.tableDate2Lsit[i].defaultMaterial == 0 ||
          requestFormTable.value.tableDate2Lsit[i].defaultMaterial == ""
        ) {
          notifications.showMessage(
            "请在物料对照表第" + [i + 1] + "行，填写数量",
            "error"
          );
          return;
        }
      }
    }
    if (formMainTable.value.measurementUnit == "组") {
      for (let i = 0; i < tableData1.value.length; i++) {
        if (
          //  tableData1.value[i].quantityWithinGroup == 0 ||
          tableData1.value[i].quantityWithinGroup == ""
        ) {
          notifications.showMessage(
            "请在中机构组设置中第" + [i + 1] + "行，填写组内数量",
            "error"
          );
          return;
        }
      }
    }
    for (let i = 0; i < tableData3.value.length; i++) {
      if (tableData3.value[i].color == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写颜色", "error");
        return;
      }
      if (tableData3.value[i].material == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写材质", "error");
        return;
      }
      if (tableData3.value[i].specification == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写规格", "error");
        return;
      }
      if (tableData3.value[i].model == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写型号", "error");
        return;
      }
      // 耗材类别
      //工作辊
      if (formMainTable.value.consumableCategory == 0) {
        if (
          tableData3.value[i].workingFaceLength == ""
          //  ||
          //  tableData3.value[i].workingFaceLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面长度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          //   || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].minHardness == ""
          //  ||
          //  tableData3.value[i].minHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxHardness == ""
          //  ||
          //  tableData3.value[i].maxHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大硬度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].minWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].minWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minNonWorkingFaceOuterDiameter == ""
          //   ||
          //  tableData3.value[i].minNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxNonWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].grindingTotal == ""
          //  ||
          //  tableData3.value[i].grindingTotal == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写磨削总量",
            "error"
          );
          return;
        }
        //   if (
        //     tableData3.value[i].workingFaceControlLogic == "" ||
        //     tableData3.value[i].workingFaceControlLogic == 0
        //   ) {
        //     notifications.showMessage(
        //       "请在标准设置中第" + [i + 1] + "行，填写工作面控制逻辑",
        //       "error"
        //     );
        //     return;
        //   }

        if (
          tableData3.value[i].minRoughness == ""
          //  ||
          //  tableData3.value[i].minRoughness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小粗糙度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxRoughness == ""
          //   ||
          //  tableData3.value[i].maxRoughness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大粗糙度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minTaper == ""
          //   || tableData3.value[i].minTaper == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小锥度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxTaper == ""
          // || tableData3.value[i].maxTaper == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大锥度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].taperLength == ""
          //  ||
          //  tableData3.value[i].taperLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写锥长",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].taperHeight == ""
          //  ||
          //  tableData3.value[i].taperHeigh == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写锥高",
            "error"
          );
          return;
        }
      }
      if (
        formMainTable.value.consumableCategory == 1 ||
        formMainTable.value.consumableCategory == 2
      ) {
        if (
          tableData3.value[i].workingFaceLength == ""
          //   ||
          //  tableData3.value[i].workingFaceLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面长度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].weight == ""
          // || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          //   || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minThickness == ""
          //  ||
          //  tableData3.value[i].minThickness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小厚度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //   ||
          //  tableData3.value[i].maxThickness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大厚度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //  ||
          //  tableData3.value[i].minInnerHole == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小内孔",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //  ||
          //  tableData3.value[i].maxInnerHole == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大内孔",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minHardness == ""
          //   ||
          //  tableData3.value[i].minHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxHardness == ""
          //   ||
          //  tableData3.value[i].maxHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].minWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxWorkingFaceOuterDiameter == ""
          //   ||
          //  tableData3.value[i].maxWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minNonWorkingFaceOuterDiameter == ""
          //   ||
          //  tableData3.value[i].minNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxNonWorkingFaceOuterDiameter == ""
          //   ||
          //  tableData3.value[i].maxNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].grindingTotal == ""
          //  ||
          //  tableData3.value[i].grindingTotal == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写磨削总量",
            "error"
          );
          return;
        }
        //   if (
        //     tableData3.value[i].workingFaceControlLogic == "" ||
        //     tableData3.value[i].workingFaceControlLogic == 0
        //   ) {
        //     notifications.showMessage(
        //       "请在标准设置中第" + [i + 1] + "行，填写工作面控制逻辑",
        //       "error"
        //     );
        //     return;
        //   }
      }
      if (formMainTable.value.consumableCategory == 3) {
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          // || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].volume == ""
          //   || tableData3.value[i].volume == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写体积",
            "error"
          );
          return;
        }
      }
      if (formMainTable.value.consumableCategory == 4) {
        if (
          tableData3.value[i].weight == ""
          // || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          // || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
      }
    }
    console.log(requestFormTable.value);
    const res = await crud.sendRequest(
      "/Equ/update/Equipment/Structure",
      "post",
      requestFormTable.value
    );
    isDiable.value = true;

    // 在此处执行第二个异步操作
    await fetchSecondAsyncOperation();
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const getAllData1 = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认保存", "success");
    if (!result) {
      return;
    }
    if (!formMainTable.value.M0ID) {
      notifications.showMessage("请先保存主表内容", "error");
      return;
    }
    if (formMainTable.value.quantity == 0) {
      notifications.showMessage("数量不为0", "error");
      return;
    }
    if (formMainTable.value.componentName == "") {
      notifications.showMessage("请选择零件", "error");
      return;
    }
    if (formMainTable.value.categoryName == "") {
      notifications.showMessage("请选择类别", "error");
      return;
    }
    //  if (formMainTable.value.replacementCycleMethod == "") {
    //    notifications.showMessage("请输入更换方式", "error");
    //    return;
    //  }
    //  if (formMainTable.value.cycleDays === "") {
    //    notifications.showMessage("请输入周期天数", "error");
    //    return;
    //  }
    //  if (formMainTable.value.replacementCycleDailyOutput == 0) {
    //    notifications.showMessage("定额产量不能为0", "error");
    //    return;
    //  }

    //  if (requestFormTable.value.tableDate2Lsit.length == 0) {
    //    notifications.showMessage("物料对照表不能为空", "error");
    //    return;
    //  }
    for (let i = 0; i < requestFormTable.value.tableDate2Lsit.length; i++) {
      if (requestFormTable.value.tableDate2Lsit[i].k3Code != "") {
        if (
          //  requestFormTable.value.tableDate2Lsit[i].defaultMaterial == 0 ||
          requestFormTable.value.tableDate2Lsit[i].defaultMaterial == ""
        ) {
          notifications.showMessage(
            "请在物料对照表第" + [i + 1] + "行，填写数量",
            "error"
          );
          return;
        }
      }
    }
    if (formMainTable.value.measurementUnit == "组") {
      for (let i = 0; i < tableData1.value.length; i++) {
        if (
          //  tableData1.value[i].quantityWithinGroup == 0 ||
          tableData1.value[i].quantityWithinGroup == ""
        ) {
          notifications.showMessage(
            "请在中机构组设置中第" + [i + 1] + "行，填写组内数量",
            "error"
          );
          return;
        }
      }
    }
    for (let i = 0; i < tableData3.value.length; i++) {
      if (tableData3.value[i].color == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写颜色", "error");
        return;
      }
      if (tableData3.value[i].material == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写材质", "error");
        return;
      }
      if (tableData3.value[i].specification == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写规格", "error");
        return;
      }
      if (tableData3.value[i].model == "") {
        notifications.showMessage("请在标准设置中第" + [i + 1] + "行，填写型号", "error");
        return;
      }
      if (tableData3.value[i].outsideDiameterStandard == "") {
        notifications.showMessage(
          "请在标准设置中第" + [i + 1] + "行，填写外径公差标准",
          "error"
        );
        return;
      }
      if (tableData3.value[i].minOutsideDiameter == "") {
        notifications.showMessage(
          "请在标准设置中第" + [i + 1] + "行，填写外径公差上限",
          "error"
        );
        return;
      }
      if (tableData3.value[i].maxOutsideDiameter == "") {
        notifications.showMessage(
          "请在标准设置中第" + [i + 1] + "行，填写外径公差下限",
          "error"
        );
        return;
      }
      // 耗材类别
      //工作辊
      if (formMainTable.value.consumableCategory == 0) {
        if (
          tableData3.value[i].workingFaceLength == ""
          //  || tableData3.value[i].workingFaceLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面长度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          //   || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          // || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].minHardness == ""
          //  ||
          //  tableData3.value[i].minHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxHardness == ""
          //  ||
          //  tableData3.value[i].maxHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大硬度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].minWorkingFaceOuterDiameter == ""
          //   ||
          //  tableData3.value[i].minWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minNonWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].minNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxNonWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].grindingTotal == ""
          //  ||
          //  tableData3.value[i].grindingTotal == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写磨削总量",
            "error"
          );
          return;
        }
        //   if (
        //     tableData3.value[i].workingFaceControlLogic == "" ||
        //     tableData3.value[i].workingFaceControlLogic == 0
        //   ) {
        //     notifications.showMessage(
        //       "请在标准设置中第" + [i + 1] + "行，填写工作面控制逻辑",
        //       "error"
        //     );
        //     return;
        //   }

        if (
          tableData3.value[i].minRoughness == ""
          //  ||
          //  tableData3.value[i].minRoughness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小粗糙度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxRoughness == ""
          //  ||
          //  tableData3.value[i].maxRoughness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大粗糙度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minTaper == ""
          //   || tableData3.value[i].minTaper == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小锥度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxTaper == ""
          //   || tableData3.value[i].maxTaper == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大锥度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].taperLength == ""
          //  ||
          //  tableData3.value[i].taperLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写锥长",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].taperHeight == ""
          //  ||
          //  tableData3.value[i].taperHeigh == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写锥高",
            "error"
          );
          return;
        }
      }
      if (
        formMainTable.value.consumableCategory == 1 ||
        formMainTable.value.consumableCategory == 2
      ) {
        if (
          tableData3.value[i].workingFaceLength == ""
          //  ||
          //  tableData3.value[i].workingFaceLength == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面长度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          // || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minThickness == ""
          //  ||
          //  tableData3.value[i].minThickness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小厚度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //  ||
          //  tableData3.value[i].maxThickness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大厚度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //  ||
          //  tableData3.value[i].minInnerHole == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小内孔",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxThickness == ""
          //  ||
          //  tableData3.value[i].maxInnerHole == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大内孔",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minHardness == ""
          //  ||
          //  tableData3.value[i].minHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最小硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxHardness == ""
          //  ||
          //  tableData3.value[i].maxHardness == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写最大硬度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].minWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].minNonWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].minNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最小外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].maxNonWorkingFaceOuterDiameter == ""
          //  ||
          //  tableData3.value[i].maxNonWorkingFaceOuterDiameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写非工作面最大外径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].grindingTotal == ""
          //  ||
          //  tableData3.value[i].grindingTotal == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写磨削总量",
            "error"
          );
          return;
        }
        //   if (
        //     tableData3.value[i].workingFaceControlLogic == "" ||
        //     tableData3.value[i].workingFaceControlLogic == 0
        //   ) {
        //     notifications.showMessage(
        //       "请在标准设置中第" + [i + 1] + "行，填写工作面控制逻辑",
        //       "error"
        //     );
        //     return;
        //   }
      }
      if (formMainTable.value.consumableCategory == 3) {
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          //   || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].volume == ""
          //   || tableData3.value[i].volume == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写体积",
            "error"
          );
          return;
        }
      }
      if (formMainTable.value.consumableCategory == 4) {
        if (
          tableData3.value[i].weight == ""
          //   || tableData3.value[i].weight == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写重量",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].length == ""
          //   || tableData3.value[i].length == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写长度",
            "error"
          );
          return;
        }

        if (
          tableData3.value[i].width == ""
          //   || tableData3.value[i].width == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写宽度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].height == ""
          //   || tableData3.value[i].height == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写高度",
            "error"
          );
          return;
        }
        if (
          tableData3.value[i].diameter == ""
          //   || tableData3.value[i].diameter == 0
        ) {
          notifications.showMessage(
            "请在标准设置中第" + [i + 1] + "行，填写直径",
            "error"
          );
          return;
        }
      }
    }
    console.log(requestFormTable.value);
    const res = await crud.sendRequest(
      "/Equ/add/EquipmentStructure/ChileChild",
      "post",
      requestFormTable.value
    );
    isDiable.value = true;

    // 在此处执行第二个异步操作
    await fetchSecondAsyncOperation();
  } catch (error) {
    console.error("请求失败:", error);
  }
};

const fetchSecondAsyncOperation = async () => {
  try {
    const res = await crud.fetchData(
      "/Equ/select/EquipmentStructureChild/All",
      "post",
      requestFormTable.value
    );
    tableEle4.value = res;
  } catch (error) {
    console.error("请求失败:", error);
  }
};

const getSelectedData = () => {
  const selectedRows = multipleTableRef.value.getSelectionRows();
  console.log("Selected Data:", selectedRows);
};

const deleteSelectedRows = () => {
  const selectedRows = multipleTableRef.value.getSelectionRows();
  selectedRows.forEach((row) => {
    const index = tableData1.value.indexOf(row);
    if (index !== -1) {
      tableData1.value.splice(index, 1);
    }
  });
};
const deleteRow3 = (row: any) => {
  console.log(row);
  const index = tableData3.value.indexOf(row);
  if (index != -1) {
    tableData3.value.splice(index, 1);
  }
};

const deleteRow = (row: any) => {
  console.log(row);
  const index = tableData2.value.indexOf(row);
  if (index != -1) {
    tableData2.value.splice(index, 1);
  }
};
const headerCellStyle1 = {
  borderColor: "#B9C9C7",
  backgroundColor: "#F2F4FA",
  fontWeight: "bold",
  color: "#1F2129",
  height: "40px",
  margin: 0,
  padding: 0,
};
// 弹窗
const indexEmployeeJob = ref(0);
const openEmployeeJob1 = (row) => {
  indexEmployeeJob.value = tableData2.value.indexOf(row);
  sec.value.dialogTableVisible = true;
  openDial1();
};
const openEmployeeJob = (index) => {
  sea.value.dialogTableVisible = true;
  openDial();
};

const openEmployeeJob2 = (index) => {
  sed.value.dialogTableVisible = true;
  openDial2();
};
const indexEmpCz = ref(0);
const openEmployeeJob3 = async (index) => {
  indexEmpCz.value = index;
  seb.value.dialogTableVisible = true;
  openDial3();
};

const sea = ref<any>(null);
const sec = ref<any>(null);
const sed = ref<any>(null);
const seb = ref<any>(null);
const tableDemo1 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  // { type: "selection", width: "65", align: "center" },
  //   { prop: "id", label: "Id", width: "120", align: "center" },
  { prop: "fnumber", label: "编码", width: "120", align: "center" },
  { prop: "bmmc", label: "k3名称", width: "150", align: "center" },
  { prop: "wlgg", label: "物料规格", width: "150", align: "center" },
  { prop: "jldw", label: "计量单位", width: "150", align: "center" },
]);
const tableDemo = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  // { type: "selection", width: "65", align: "center" },
  //   { prop: "id", label: "Id", width: "120", align: "center" },
  { prop: "code", label: "编码", width: "120", align: "center" },
  { prop: "name", label: "名称", width: "150", align: "center" },
  { prop: "description", label: "备注", width: "150", align: "center" },
]);
const tableDemo2 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  { type: "selection", width: "65", align: "center" },
  //   { prop: "cid", label: "ID", width: "120", align: "center" },
  { prop: "ccode", label: "项目编号", width: "120", align: "center" },
  { prop: "cname", label: "项目名称", width: "150", align: "center" },
  { prop: "cdescription", label: "说明", width: "150", align: "center" },
]);
const tableDemo3 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "ytbm", label: "编码", width: "120", align: "center" },
  { prop: "ytfl", label: "分类", width: "120", align: "center" },
  { prop: "ytmc", label: "用途", width: "150", align: "center" },
  { prop: "remark", label: "备注", width: "150", align: "center" },
]);
const openDial2 = (row: any) => {
  sed.value.dynamicPlaceholder1 = "项目名称";
  sed.value.ifdynamic2 = false;
  sed.value.ifdynamic3 = false;
  sed.value.tableColumns = tableDemo2.value;
  sed.value.apiUrl = "/Comp/select/Child/Auto1";
  sed.value.searchInput();
};
const openDial = (row: any) => {
  sea.value.ifdynamic1 = false;
  sea.value.ifdynamic2 = false;
  sea.value.ifdynamic3 = false;
  sea.value.tableColumns = tableDemo.value;
  sea.value.apiUrl = "/select/ComponentMechanicalUsageCategory/AllAuyo1";
  sea.value.searchInput();
};
const openDial1 = (row: any) => {
  sec.value.ifdynamic1 = true;
  sec.value.ifdynamic2 = true;
  sec.value.dynamicPlaceholder1 = "物料编码";
  sec.value.dynamicPlaceholder2 = "物料名称";
  sec.value.ifdynamic3 = false;
  sec.value.tableColumns = tableDemo1.value;
  sec.value.apiUrl = "/get/K3bm/Mc";
  sec.value.searchInput();
  //多选调整
  sec.value.compareValue = "id";
  sec.value.ifRowChoose = true;
};
const openDial3 = () => {
  seb.value.ifRowChoose = false;
  seb.value.ifdynamic1 = true;
  seb.value.ifdynamic2 = true;
  seb.value.ifdynamic3 = true;
  seb.value.dynamicPlaceholder1 = "材质编码";
  seb.value.dynamicPlaceholder2 = "材质分类";
  seb.value.dynamicPlaceholder3 = "材质名称";
  seb.value.tableColumns = tableDemo3.value;
  seb.value.apiUrl = "/Mat/Select/UseDefinition/Mc/A";
  seb.value.searchInput();
};
const handleRowData3 = async (row) => {
  const index = indexEmpCz.value;
  //   formMainTable.value.material = row.id;
  tableData3.value[index].material = row.ytmc;
};
const handleRowData = (row) => {
  console.log('"rowData" 事件触发，行数据为：', row);
  console.log(formMainTable.value);
  formMainTable.value.categoryID = row.id;
  formMainTable.value.categoryName = row.name;
};
const handleRowData2 = (row) => {
  console.log('"rowData" 事件触发，行数据为：', row);
  console.log(formMainTable);
  formMainTable.value.componentID = row.cid;
  formMainTable.value.componentName = row.cname;
};
const handleRowDatas = (row) => {
  //   const index = indexEmployeeJob.value;
  //   for (let i = 0; i < row.length; i++) {
  //     const newUserId = row[i].userId;
  //     // 验证是否存在重复的userId
  //     const isDuplicate = tableData1.value.some((item) => item.personnelID === newUserId);
  //     if (isDuplicate) {
  //       notifications.showMessage(
  //         `已经存在 userId 为 ${newUserId} 的记录，不能重复添加，序号为 ${i + 1}`,
  //         "error"
  //       );
  //       return;
  //     }
  //     tableData1.value[index + i].personnelID = newUserId;
  //     tableData1.value[index + i].name = row[i].name;
  //     tableData1.value[index + i].jobID = row[i].jobId;
  //     tableData1.value[index + i].jobName = row[i].jobName;
  //   }
};

const handleRowDatas1 = (row) => {
  const index = indexEmployeeJob.value;
  const rowLength = row.length;
  // 遍历 row，为 tableData2 中的每行赋值
  for (let i = 0; i < rowLength; i++) {
    const targetIndex = index + i;
    if (targetIndex >= tableData2.value.length) {
      break;
    }

    const fnumber = row[i].fnumber;
    // 验证是否存在重复的 userId
    const isDuplicate = tableData2.value.some((item) => item.k3Code === fnumber);

    if (isDuplicate) {
      notifications.showMessage(
        `已经存在 物料编码 为 ${fnumber} 的记录，不能重复添加，序号为 ${i + 1}`,
        "error"
      );
      continue; // 如果重复，则继续处理下一行数据
    }

    // 为 tableData2 中的每行赋值
    tableData2.value[targetIndex].k3Code = fnumber;
    tableData2.value[targetIndex].k3Name = row[i].bmmc;
    tableData2.value[targetIndex].materialID = row[i].id;
  }
};

// 弹窗测试
const value = ref("");
// 表单规则
interface RuleForm {
  id: string;
  businessTypeID: string;
  businessTypeName: string;
  structureCode: string;
  structureName: string;
  versionStatus: boolean;
  version: string;
  majorVersion: string;
  minorVersion: string;
  revisionVersion: string;
  description: string;
  cID: string;
  M0ID: string;
  componentID: string;
  componentName: string;
  categoryName: string;
  categoryID: string;
  parentID: number;
  level: number;
  isLeaf: string;
  isSplit: string;
  isSplitLeftRight: string;
  measurementUnit: string;
  quantity: number;
  replacementCycleMethod: string;
  cycleDays: string;
  replacementCycleDailyOutput: number;
  partAttributes: string;
  upperCount: number;
  lowerCount: number;
  leftCount: number;
  rightCount: number;
  upperLeftCount: number;
  upperRightCount: number;
  lowerLeftCount: number;
  lowerRightCount: number;
  upperUnit: string;
  lowerUnit: string;
  leftUnit: string;
  rightUnit: string;
  upperLeftUnit: string;
  upperRightUnit: string;
  lowerLefUnit: string;
  lowerRighUnit: string;
  componentCategoryId: string;
  componentCategoryCode: string;
  componentCategoryName: string;
  componentCategoryDescription: string;
  consumableCategory: string;
}

const formMainTable = ref<RuleForm>({
  id: "",
  businessTypeID: "",
  businessTypeName: "",
  structureCode: "",
  structureName: "",
  versionStatus: true,
  version: "",
  majorVersion: "",
  minorVersion: "",
  revisionVersion: "",
  description: "",
  cID: "",
  M0ID: "",
  componentID: "",
  componentName: "",
  categoryName: "",
  categoryID: "",
  parentID: 0,
  level: 0,
  isLeaf: "",
  isSplit: "0",
  isSplitLeftRight: "0",
  measurementUnit: "单件",
  quantity: 0,
  replacementCycleMethod: "",
  cycleDays: "",
  replacementCycleDailyOutput: 0,
  partAttributes: "1",
  upperCount: 0,
  lowerCount: 0,
  leftCount: 0,
  rightCount: 0,
  upperLeftCount: 0,
  upperRightCount: 0,
  lowerLeftCount: 0,
  lowerRightCount: 0,
  upperUnit: "单件",
  lowerUnit: "单件",
  leftUnit: "单件",
  rightUnit: "单件",
  upperLeftUnit: "单件",
  upperRightUnit: "单件",
  lowerLefUnit: "单件",
  lowerRighUnit: "单件",
  componentCategoryId: "",
  componentCategoryCode: "",
  componentCategoryName: "",
  componentCategoryDescription: "0",
  //参数表：
  consumableCategory: "0", //耗材类别
} as any);
const isDisableduplo = ref(true);
const isDisabledleri = ref(true);
const isDisableduploleri = ref(true);
const isDisabledquantity = ref(false);
const shouDao = ref(true);
const shouGun = ref(false);
const shouGx = ref(true);
const handleConsumableCategory = () => {
  if (formMainTable.value.consumableCategory == 0) {
    shouDao.value = true;
    shouGun.value = false;
    shouGx.value = true;
  }
  if (formMainTable.value.consumableCategory == 1) {
    shouDao.value = false;
    shouGun.value = true;
    shouGx.value = true;
  }
  if (formMainTable.value.consumableCategory == 2) {
    shouDao.value = false;
    shouGun.value = true;
    shouGx.value = true;
  }
  if (formMainTable.value.consumableCategory == 3) {
    shouDao.value = true;
    shouGun.value = true;
    shouGx.value = false;
  }
  if (formMainTable.value.consumableCategory == 4) {
    shouDao.value = true;
    shouGun.value = true;
    shouGx.value = true;
  }
  handleMeasurementUnit();
};
watch(
  () => formMainTable.value.quantity,
  (newValue, oldValue) => {
    //  tableData2.value = [];

    //  for (let i = 0; i < newValue; i++) {
    //    tableData2.value.push({
    //      ...defaultRowData2,
    //    });
    //  }

    handleMeasurementUnit();
  },
  { deep: true }
);
const handleMeasurementUnit = () => {
  var upperLeftCount = parseInt(formMainTable.value.upperLeftCount); //上左
  var upperRightCount = parseInt(formMainTable.value.upperRightCount); //上右
  var lowerLeftCount = parseInt(formMainTable.value.lowerLeftCount); //下左
  var lowerRightCount = parseInt(formMainTable.value.lowerRightCount); //下右
  var upperCount = parseInt(formMainTable.value.upperCount); //上
  var lowerCount = parseInt(formMainTable.value.lowerCount); //下
  var leftCount = parseInt(formMainTable.value.leftCount); //左
  var rightCount = parseInt(formMainTable.value.rightCount); //右
  var quantity = parseInt(formMainTable.value.quantity); //总数
  tableData1.value = [];

  if (formMainTable.value.measurementUnit == "单件") {
    tableData1.value = [];
    return;
  }

  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "0") {
    for (let i = 0; i < quantity; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "无",
      });
    }
    return;
  }
  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "1") {
    for (let i = 0; i < leftCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "左" + (i + 1),
      });
    }

    for (let i = 0; i < rightCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "右" + (i + 1),
      });
    }
    return;
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "0") {
    for (let i = 0; i < upperCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "上" + (i + 1),
      });
    }

    for (let i = 0; i < lowerCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "下" + (i + 1),
      });
    }
    return;
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "1") {
    for (let i = 0; i < upperLeftCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "上左" + (i + 1),
      });
    }
    for (let i = 0; i < upperRightCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "上右" + (i + 1),
      });
    }
    for (let i = 0; i < lowerLeftCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "下左" + (i + 1),
      });
    }
    for (let i = 0; i < lowerRightCount; i++) {
      tableData1.value.push({
        ...defaultRowData,
        groupNumber: "下右" + (i + 1),
      });
    }
    return;
  }
};
watch(
  () => ({
    isSplit: formMainTable.value.isSplit,
    isSplitLeftRight: formMainTable.value.isSplitLeftRight,
  }),
  (newValues, oldValues) => {
    // const { isSplit, isSplitLeftRight } = newValues;
    // const { isSplit: oldIsSplit, isSplitLeftRight: oldIsSplitLeftRight } = oldValues;

    //  tableData2.value = [];

    //  for (let i = 0; i < newValues.isSplit; i++) {
    //    tableData2.value.push({
    //      ...defaultRowData2,
    //    });
    //  }

    watchOrganizationSelect();
  },
  { deep: true }
);
const watchOrganizationSelect = () => {
  tableData1.value = [];
  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "0") {
    formMainTable.value.upperCount = 0;
    formMainTable.value.lowerCount = 0;
    formMainTable.value.leftCount = 0;
    formMainTable.value.rightCount = 0;
    formMainTable.value.upperLeftCount = 0;
    formMainTable.value.upperRightCount = 0;
    formMainTable.value.lowerLeftCount = 0;
    formMainTable.value.lowerRightCount = 0;
    isDisabledleri.value = true; //左右
    isDisableduplo.value = true; //上下
    isDisableduploleri.value = true; //xxxx
    isDisabledquantity.value = false; //数量
  }
  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "1") {
    formMainTable.value.upperCount = 0;
    formMainTable.value.lowerCount = 0;
    formMainTable.value.upperLeftCount = 0;
    formMainTable.value.upperRightCount = 0;
    formMainTable.value.lowerLeftCount = 0;
    formMainTable.value.lowerRightCount = 0;
    isDisabledleri.value = false; //左右
    isDisableduplo.value = true; //上下
    isDisableduploleri.value = true; //xxxx
    isDisabledquantity.value = true; //数量
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "0") {
    formMainTable.value.leftCount = 0;
    formMainTable.value.rightCount = 0;
    formMainTable.value.upperLeftCount = 0;
    formMainTable.value.upperRightCount = 0;
    formMainTable.value.lowerLeftCount = 0;
    formMainTable.value.lowerRightCount = 0;
    isDisabledleri.value = true; //左右
    isDisableduplo.value = false; //上下
    isDisableduploleri.value = true; //xxxx
    isDisabledquantity.value = true; //数量
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "1") {
    formMainTable.value.upperCount = 0;
    formMainTable.value.lowerCount = 0;
    formMainTable.value.leftCount = 0;
    formMainTable.value.rightCount = 0;
    isDisabledleri.value = true; //左右
    isDisableduplo.value = true; //上下
    isDisableduploleri.value = false; //xxxx
    isDisabledquantity.value = true; //数量
  }
};
const clickOrganizationSelect = () => {
  //   tableData1.value = [];
  //   if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "0") {
  //     formMainTable.value.upperCount = 0;
  //     formMainTable.value.lowerCount = 0;
  //     formMainTable.value.leftCount = 0;
  //     formMainTable.value.rightCount = 0;
  //     formMainTable.value.upperLeftCount = 0;
  //     formMainTable.value.upperRightCount = 0;
  //     formMainTable.value.lowerLeftCount = 0;
  //     formMainTable.value.lowerRightCount = 0;
  //     isDisabledleri.value = true; //左右
  //     isDisableduplo.value = true; //上下
  //     isDisableduploleri.value = true; //xxxx
  //     isDisabledquantity.value = false; //数量
  //   }
  //   if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "1") {
  //     formMainTable.value.upperCount = 0;
  //     formMainTable.value.lowerCount = 0;
  //     formMainTable.value.upperLeftCount = 0;
  //     formMainTable.value.upperRightCount = 0;
  //     formMainTable.value.lowerLeftCount = 0;
  //     formMainTable.value.lowerRightCount = 0;
  //     isDisabledleri.value = false; //左右
  //     isDisableduplo.value = true; //上下
  //     isDisableduploleri.value = true; //xxxx
  //     isDisabledquantity.value = true; //数量
  //   }
  //   if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "0") {
  //     formMainTable.value.leftCount = 0;
  //     formMainTable.value.rightCount = 0;
  //     formMainTable.value.upperLeftCount = 0;
  //     formMainTable.value.upperRightCount = 0;
  //     formMainTable.value.lowerLeftCount = 0;
  //     formMainTable.value.lowerRightCount = 0;
  //     isDisabledleri.value = true; //左右
  //     isDisableduplo.value = false; //上下
  //     isDisableduploleri.value = true; //xxxx
  //     isDisabledquantity.value = true; //数量
  //   }
  //   if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "1") {
  //     formMainTable.value.upperCount = 0;
  //     formMainTable.value.lowerCount = 0;
  //     formMainTable.value.leftCount = 0;
  //     formMainTable.value.rightCount = 0;
  //     isDisabledleri.value = true; //左右
  //     isDisableduplo.value = true; //上下
  //     isDisableduploleri.value = false; //xxxx
  //     isDisabledquantity.value = true; //数量
  //   }
};
const handleTableDate3 = (prop, row) => {
  const index = tableData3.value.indexOf(row);
  const valString = tableData3.value[index][prop].replace(/,/g, "");
  const val = parseFloat(valString);

  if (!isNaN(val) && isFinite(val)) {
    const roundedVal = val.toFixed(4);
    const formattedVal = formatNumberToCurrency(roundedVal);
    tableData3.value[index][prop] = formattedVal;
  } else {
    tableData3.value[index][prop] = "";
  }
  //厚度标准
  //   if (
  //     tableData3.value[index].minThickness != "" &&
  //     tableData3.value[index].maxThickness != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minThickness);
  //     const val1 = parseFloat(tableData3.value[index].maxThickness);
  //     if (val > val1) {
  //       tableData3.value[index].minThickness = "";
  //       tableData3.value[index].maxThickness = "";
  //       tableData3.value[index].thicknessStandard = "";
  //       return;
  //     }
  //   }
  //内孔标准
  //   if (
  //     tableData3.value[index].minInnerHole != "" &&
  //     tableData3.value[index].maxInnerHole != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minInnerHole);
  //     const val1 = parseFloat(tableData3.value[index].maxInnerHole);
  //     if (val > val1) {
  //       tableData3.value[index].minInnerHole = "";
  //       tableData3.value[index].maxInnerHole = "";
  //       tableData3.value[index].innerHoleStandard = "";
  //       return;
  //     }
  //   }
  //硬度标准
  //   if (
  //     tableData3.value[index].minHardness != "" &&
  //     tableData3.value[index].maxHardness != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minHardness);
  //     const val1 = parseFloat(tableData3.value[index].maxHardness);
  //     if (val > val1) {
  //       tableData3.value[index].minHardness = "";
  //       tableData3.value[index].maxHardness = "";
  //       tableData3.value[index].hardnessStandard = "";
  //       return;
  //     }
  //   }
  //工作面外径标准
  //   if (
  //     tableData3.value[index].minWorkingFaceOuterDiameter != "" &&
  //     tableData3.value[index].maxWorkingFaceOuterDiameter != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minWorkingFaceOuterDiameter);
  //     const val1 = parseFloat(tableData3.value[index].maxWorkingFaceOuterDiameter);
  //     if (val > val1) {
  //       tableData3.value[index].minWorkingFaceOuterDiameter = "";
  //       tableData3.value[index].maxWorkingFaceOuterDiameter = "";
  //       tableData3.value[index].workingFaceOuterDiameterStandard = "";
  //       return;
  //     }
  //   }
  //非工作面外径标准
  //   if (
  //     tableData3.value[index].minNonWorkingFaceOuterDiameter != "" &&
  //     tableData3.value[index].maxNonWorkingFaceOuterDiameter != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minNonWorkingFaceOuterDiameter);
  //     const val1 = parseFloat(tableData3.value[index].maxNonWorkingFaceOuterDiameter);
  //     if (val > val1) {
  //       tableData3.value[index].minNonWorkingFaceOuterDiameter = "";
  //       tableData3.value[index].maxNonWorkingFaceOuterDiameter = "";
  //       tableData3.value[index].nonWorkingFaceOuterDiameterStandard = "";
  //       return;
  //     }
  //   }
  //粗糙度标准
  //   if (
  //     tableData3.value[index].minRoughness != "" &&
  //     tableData3.value[index].maxRoughness != ""
  //   ) {
  //     const val = parseFloat(tableData3.value[index].minRoughness);
  //     const val1 = parseFloat(tableData3.value[index].maxRoughness);
  //     if (val > val1) {
  //       tableData3.value[index].minRoughness = "";
  //       tableData3.value[index].maxRoughness = "";
  //       tableData3.value[index].roughnessStandard = "";
  //       return;
  //     }
  //   }
  //锥度标准
  //   if (tableData3.value[index].minTaper != "" && tableData3.value[index].maxTaper != "") {
  //     const val = parseFloat(tableData3.value[index].minTaper);
  //     const val1 = parseFloat(tableData3.value[index].maxTaper);
  //     if (val > val1) {
  //       tableData3.value[index].minTaper = "";
  //       tableData3.value[index].maxTaper = "";
  //       tableData3.value[index].taperStandard = "";
  //       return;
  //     }
  //   }
};
const handleTableDate4 = (prop, row) => {
  const index = tableData2.value.indexOf(row);
  const valString = tableData2.value[index][prop].replace(/,/g, "");
  const val = parseFloat(valString);

  if (!isNaN(val) && isFinite(val)) {
    const roundedVal = val.toFixed(0);
    const formattedVal = formatNumberToCurrency(roundedVal);
    tableData2.value[index][prop] = formattedVal;
  } else {
    tableData2.value[index][prop] = "";
  }
};
const handleInput = (prop) => {
  if (prop === "replacementCycleDailyOutput") {
    const valString = formMainTable.value[prop].replace(/,/g, "");
    const val = parseFloat(valString);
    if (!isNaN(val) && isFinite(val)) {
      const roundedVal = val.toFixed(4);
      const formattedVal = formatNumberToCurrency(roundedVal);
      formMainTable.value[prop] = formattedVal;
    } else {
      formMainTable.value[prop] = 0;
    }
    return;
  }
  if (formMainTable.value[prop] === "") {
    formMainTable.value[prop] = 0;
  } else {
    formMainTable.value[prop] = formMainTable.value[prop].replace(/\D/g, "");
  }
  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "0") {
  }
  if (formMainTable.value.isSplit == "0" && formMainTable.value.isSplitLeftRight == "1") {
    formMainTable.value.quantity =
      parseInt(formMainTable.value.rightCount) + parseInt(formMainTable.value.leftCount);
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "0") {
    formMainTable.value.quantity =
      parseInt(formMainTable.value.upperCount) + parseInt(formMainTable.value.lowerCount);
  }
  if (formMainTable.value.isSplit == "1" && formMainTable.value.isSplitLeftRight == "1") {
    formMainTable.value.quantity =
      parseInt(formMainTable.value.upperLeftCount) +
      parseInt(formMainTable.value.upperRightCount) +
      parseInt(formMainTable.value.lowerLeftCount) +
      parseInt(formMainTable.value.lowerRightCount);
    formMainTable.value.leftCount =
      parseInt(formMainTable.value.lowerLeftCount) +
      parseInt(formMainTable.value.upperLeftCount);
    formMainTable.value.rightCount =
      parseInt(formMainTable.value.upperRightCount) +
      parseInt(formMainTable.value.lowerRightCount);
    formMainTable.value.upperCount =
      parseInt(formMainTable.value.upperLeftCount) +
      parseInt(formMainTable.value.upperRightCount);

    formMainTable.value.lowerCount =
      parseInt(formMainTable.value.lowerLeftCount) +
      parseInt(formMainTable.value.lowerRightCount);
  }
};
const dynamicHeight = ref(null);
const pageWidth = ref(null);
const getScreenHeightOpen = () => {
  dynamicHeight.value = `${window.innerHeight - 81}`;
  pageWidth.value = window.innerWidth;
};
getScreenHeightOpen();

// 业务分类下拉
const parentIDValue = ref("");
const parentIDOptions = ref([]);
const transformResToOption = (data) => {
  const transform = (items) => {
    return items.map((item) => ({
      value: item.id,
      label: item.name,
      level: item.level,
      children: item.children ? transform(item.children) : [],
    }));
  };

  return transform(data);
};
const props = {
  checkStrictly: true,
};
const requestData = computed(() => ({}));
const selectBusinessTypeAside = async () => {
  try {
    const res = await crud.fetchData(
      "/BusinessType/select/BusinessType/Aside/Auto1",
      "post",
      requestData.value
    );

    const transformedRes = transformResToOption(res);
    parentIDOptions.value = transformedRes;
  } catch (error) {
    console.error("请求失败:", error);
  }
};
selectBusinessTypeAside();
const findLevelByValue = (options, targetValue) => {
  for (const option of options) {
    // 如果当前选项的值与目标值匹配，则返回该选项的级别
    if (option.value === targetValue) {
      return option.label;
    }
    // 如果当前选项有子选项，则递归调用该函数
    if (option.children && option.children.length > 0) {
      const label = findLevelByValue(option.children, targetValue);
      // 如果在子选项中找到了目标值，则返回找到的级别
      if (label !== undefined) {
        return label;
      }
    }
  }
  // 如果未找到目标值，则返回 undefined
  return undefined;
};
const handleChange = (value) => {
  const selectedValue = value[value.length - 1];
  formMainTable.value.businessTypeID = selectedValue;
};
const tableEle = ref(null);
const tableEle3 = ref(null);
const tableEle4 = ref(null);
const selectedRows3 = ref([]);
const headehandleSelectionChange3 = (selection: any) => {
  selectedRows3.value = selection;
};
const RowClick3 = (row, selection) => {
  //   tableEle.value.toggleRowSelection(row);
  showInsertButton.value = false;
  showInsertButton1.value = true;

  isDiable.value = false;
};
const cellStyle3 = ({ row, column, rowIndex, columnIndex }) => {
  if (selectedRows.value.find((selectedRow) => selectedRow.id === row.id)) {
    return {
      backgroundColor: "#DFF0DB !important",
      borderColor: "#B9C9C7",
      padding: "4px",
    };
  } else {
    return { borderColor: "#B9C9C7", padding: "4px", margin: 0 };
  }
};
// 点击节点事件
const handleEdit4 = async (index, row) => {
  showInsertButton1.value = true;
  isDiable.value = true;
  showInsertButton1.value = false;

  try {
    const res = await crud.fetchData("/Equ/select/Equipment/ComponeChildID", "post", {
      ID: row.cid,
    });
    console.log(res);
    formMainTable.value.cID = res[0].cid;
    formMainTable.value.M0ID = res[0].m0ID;
    formMainTable.value.componentID = res[0].componentID;
    formMainTable.value.componentName = res[0].componentName;
    formMainTable.value.categoryName = res[0].categoryName;
    formMainTable.value.categoryID = res[0].categoryID;
    formMainTable.value.parentID = res[0].parentID;
    formMainTable.value.level = res[0].level;
    formMainTable.value.isLeaf = res[0].isLeaf;
    formMainTable.value.isSplit = res[0].isSplit.toString();
    formMainTable.value.isSplitLeftRight = res[0].isSplitLeftRight.toString();
    formMainTable.value.measurementUnit = res[0].measurementUnit;
    formMainTable.value.quantity = res[0].quantity;
    formMainTable.value.replacementCycleMethod = res[0].replacementCycleMethod;
    formMainTable.value.cycleDays = res[0].cycleDays;
    formMainTable.value.replacementCycleDailyOutput = res[0].replacementCycleDailyOutput;
    formMainTable.value.partAttributes = res[0].partAttributes;
    formMainTable.value.upperCount = res[0].upperCount;
    formMainTable.value.lowerCount = res[0].lowerCount;
    formMainTable.value.leftCount = res[0].leftCount;
    formMainTable.value.rightCount = res[0].rightCount;
    formMainTable.value.upperLeftCount = res[0].cupperLeftCountID;
    formMainTable.value.upperRightCount = res[0].upperRightCount;
    formMainTable.value.lowerLeftCount = res[0].lowerLeftCount;
    formMainTable.value.lowerRightCount = res[0].lowerRightCount;
    formMainTable.value.componentCategoryId = res[0].componentCategoryId;
    formMainTable.value.componentCategoryCode = res[0].componentCategoryCode;
    formMainTable.value.componentCategoryName = res[0].componentCategoryName;
    formMainTable.value.componentCategoryDescription =
      res[0].componentCategoryDescription;
    //  tableData1.value = res[0].componentStructureGroupCompositionsList;
    tableData1.value = res[0].componentStructureGroupCompositionsList.map((item) => {
      return {
        componentID: item.componentID,
        groupNumber: item.groupNumber,
        id: item.id,
        materialID: item.m1ID,
        quantityWithinGroup: item.quantityWithinGroup,
        universalBetweenGroups: item.universalBetweenGroups === 1 ? true : false,
      };
    });
    tableData2.value = res[0].equipmentComponentMaterialMappingSettingList.map((item) => {
      return {
        id: item.id,
        k3Code: item.k3Code,
        k3Name: item.k3Name,
        materialID: item.materialID,
        defaultMaterial: item.defaultMaterial,
        materialQuantity: item.materialQuantity === 1 ? "是" : "否",
      };
    });
    console.log(res[0].componentBasicInformationList);
    tableData3.value = res[0].componentBasicInformationList.map((item) => {
      return {
        id: item.id,
        informationType: item.informationType,
        equipmentStructureId: item.equipmentStructureId,
        componentId: item.componentId,
        color: item.color,
        material: item.material,
        specification: item.specification,
        controlMode: item.controlMode,
        model: item.model,
        workingFaceLength: item.workingFaceLength,
        consumableCategory: item.consumableCategory,
        allowManualScrap: item.allowManualScrap,
        weight: item.weight,
        length: item.length,
        width: item.width,
        height: item.height,
        diameter: item.diameter,
        thicknessStandard: item.thicknessStandard,
        minThickness: item.minThickness,
        maxThickness: item.maxThickness,
        innerHoleStandard: item.innerHoleStandard,
        minInnerHole: item.minInnerHole,
        maxInnerHole: item.maxInnerHole,
        hardnessStandard: item.hardnessStandard,
        minHardness: item.minHardness,
        maxHardness: item.maxHardness,
        workingFaceOuterDiameterStandard: item.workingFaceOuterDiameterStandard,
        minWorkingFaceOuterDiameter: item.minWorkingFaceOuterDiameter,
        maxWorkingFaceOuterDiameter: item.maxWorkingFaceOuterDiameter,
        nonWorkingFaceOuterDiameterStandard: item.nonWorkingFaceOuterDiameterStandard,
        minNonWorkingFaceOuterDiameter: item.minNonWorkingFaceOuterDiameter,
        maxNonWorkingFaceOuterDiameter: item.maxNonWorkingFaceOuterDiameter,
        grindingTotal: item.grindingTotal,
        workingFaceScrapControlMethod: item.workingFaceScrapControlMethod,
        workingFaceControlReferenceField: item.workingFaceControlReferenceField,
        workingFaceControlLogic: item.workingFaceControlLogic,
        roughnessStandard: item.roughnessStandard,
        minRoughness: item.minRoughness,
        maxRoughness: item.maxRoughness,
        taperStandard: item.taperStandard,
        minTaper: item.minTaper,
        maxTaper: item.maxTaper,
        taperLength: item.taperLength,
        taperHeight: item.taperHeight,
        volume: item.volume,
      };
    });
    //  tableData3.value = res[0].componentBasicInformationList;
    for (let i = 0; i < 5; i++) {
      tableData3.value.push({
        ...defaultRowData3,
      });
      tableData2.value.push({
        ...defaultRowData2,
      });
    }

    //      res[0].componentBasicInformationList.forEach(item => {
    //     tableData3.value.push({
    //       ID: item.ID,
    //       businessTypeID: item.businessTypeID,
    //       quantity: item.quantity,
    //       measurementUnit: item.measurementUnit,
    //       componentName: item.componentName,
    //     });
    //   });
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const handleEdit3 = (index, row) => {
  showInsertButton.value = false;
  showInsertButton1.value = true;
  isDiable.value = true;
  formMainTable.value.cID = "";
  formMainTable.value.componentID = "";
  formMainTable.value.componentName = "";
  formMainTable.value.categoryName = "";
  formMainTable.value.categoryID = "";
  formMainTable.value.parentID = row.cid;
  formMainTable.value.level = row.level + 1;
  formMainTable.value.isLeaf = "";
  formMainTable.value.isSplit = "0";
  formMainTable.value.isSplitLeftRight = "0";
  formMainTable.value.measurementUnit = "单件";
  formMainTable.value.quantity = 0;
  formMainTable.value.replacementCycleMethod = "";
  formMainTable.value.cycleDays = "";
  formMainTable.value.replacementCycleDailyOutput = 0;
  formMainTable.value.partAttributes = "1";
  formMainTable.value.upperCount = 0;
  formMainTable.value.lowerCount = 0;
  formMainTable.value.leftCount = 0;
  formMainTable.value.rightCount = 0;
  formMainTable.value.upperLeftCount = 0;
  formMainTable.value.upperRightCount = 0;
  formMainTable.value.lowerLeftCount = 0;
  formMainTable.value.lowerRightCount = 0;
  formMainTable.value.upperUnit = "单件";
  formMainTable.value.lowerUnit = "单件";
  formMainTable.value.leftUnit = "单件";
  formMainTable.value.rightUnit = "单件";
  formMainTable.value.upperLeftUnit = "单件";
  formMainTable.value.upperRightUnit = "单件";
  formMainTable.value.lowerLefUnit = "单件";
  formMainTable.value.lowerRighUnit = "单件";
  formMainTable.value.componentCategoryId = "";
  formMainTable.value.componentCategoryCode = "";
  formMainTable.value.componentCategoryName = "";
  formMainTable.value.componentCategoryDescription = "0";
  formMainTable.value.consumableCategory = "0";
  tableData1.value = [];

  tableData2.value = [];
  for (let i = 0; i < 20; i++) {
    tableData2.value.push({
      ...defaultRowData2,
    });
  }
  tableData3.value = [];
  for (let i = 0; i < 5; i++) {
    tableData3.value.push({
      ...defaultRowData3,
    });
  }
};
const handleEdit2 = (index, row) => {
  console.log(row);
  showInsertButton1.value = true;
  showInsertButton.value = false;
  isDiable.value = true;
  formMainTable.value.cID = "";
  formMainTable.value.componentID = "";
  formMainTable.value.componentName = "";
  formMainTable.value.categoryName = "";
  formMainTable.value.categoryID = "";
  formMainTable.value.parentID = row.parentID;
  formMainTable.value.level = row.level;
  formMainTable.value.isLeaf = "";
  formMainTable.value.isSplit = "0";
  formMainTable.value.isSplitLeftRight = "0";
  formMainTable.value.measurementUnit = "单件";
  formMainTable.value.quantity = 0;
  formMainTable.value.replacementCycleMethod = "";
  formMainTable.value.cycleDays = "";
  formMainTable.value.replacementCycleDailyOutput = 0;
  formMainTable.value.partAttributes = "1";
  formMainTable.value.upperCount = 0;
  formMainTable.value.lowerCount = 0;
  formMainTable.value.leftCount = 0;
  formMainTable.value.rightCount = 0;
  formMainTable.value.upperLeftCount = 0;
  formMainTable.value.upperRightCount = 0;
  formMainTable.value.lowerLeftCount = 0;
  formMainTable.value.lowerRightCount = 0;
  formMainTable.value.upperUnit = "单件";
  formMainTable.value.lowerUnit = "单件";
  formMainTable.value.leftUnit = "单件";
  formMainTable.value.rightUnit = "单件";
  formMainTable.value.upperLeftUnit = "单件";
  formMainTable.value.upperRightUnit = "单件";
  formMainTable.value.lowerLefUnit = "单件";
  formMainTable.value.lowerRighUnit = "单件";
  formMainTable.value.componentCategoryId = "";
  formMainTable.value.componentCategoryCode = "";
  formMainTable.value.componentCategoryName = "";
  formMainTable.value.componentCategoryDescription = "0";
  formMainTable.value.consumableCategory = "0";
  tableData1.value = [];
  tableData2.value = [];
  for (let i = 0; i < 5; i++) {
    tableData2.value.push({
      ...defaultRowData2,
    });
  }
  tableData3.value = [];
  for (let i = 0; i < 5; i++) {
    tableData3.value.push({
      ...defaultRowData3,
    });
  }
};

const handleEdit1 = (row, selection) => {
  //   showInsertButton.value = false;
  //   isDiable.value = false;
  //   formMainTable.value.cID = "";
  //   formMainTable.value.componentID = "";
  //   formMainTable.value.componentName = "";
  //   formMainTable.value.categoryName = "";
  //   formMainTable.value.categoryID = "";
  //   formMainTable.value.parentID = 0;
  //   formMainTable.value.level = 0;
  //   formMainTable.value.isLeaf = "";
  //   formMainTable.value.isSplit = "0";
  //   formMainTable.value.isSplitLeftRight = "0";
  //   formMainTable.value.measurementUnit = "单件";
  //   formMainTable.value.quantity = 0;
  //   formMainTable.value.replacementCycleMethod = "";
  //   formMainTable.value.cycleDays = "";
  //   formMainTable.value.replacementCycleDailyOutput = 0;
  //   formMainTable.value.partAttributes = "1";
  //   formMainTable.value.upperCount = 0;
  //   formMainTable.value.lowerCount = 0;
  //   formMainTable.value.leftCount = 0;
  //   formMainTable.value.rightCount = 0;
  //   formMainTable.value.upperLeftCount = 0;
  //   formMainTable.value.upperRightCount = 0;
  //   formMainTable.value.lowerLeftCount = 0;
  //   formMainTable.value.lowerRightCount = 0;
  //   formMainTable.value.upperUnit = "单件";
  //   formMainTable.value.lowerUnit = "单件";
  //   formMainTable.value.leftUnit = "单件";
  //   formMainTable.value.rightUnit = "单件";
  //   formMainTable.value.upperLeftUnit = "单件";
  //   formMainTable.value.upperRightUnit = "单件";
  //   formMainTable.value.lowerLefUnit = "单件";
  //   formMainTable.value.lowerRighUnit = "单件";
  //   formMainTable.value.componentCategoryId = "";
  //   formMainTable.value.componentCategoryCode = "";
  //   formMainTable.value.componentCategoryName = "";
  //   formMainTable.value.componentCategoryDescription = "0";
  //   formMainTable.value.consumableCategory = "0";
  //   tableData1.value = [];
  //   tableData2.value = [];
  //   tableData3.value = [];
};
</script>
<style scoped>
.el-table {
  /* --el-table-row-hover-bg-color: rgba(0, 158, 250, 0.219) !important; */
  /* --el-table-row-hover-bg-color: #fef5f0 !important; */
  --el-table-row-hover-bg-color: rgba(254, 245, 240, 0.8) !important;
}

/* 选中 */
.el-table {
  /* --el-table-row-hover-bg-color: #fef5f0 !important; */
  --el-table-row-hover-bg-color: rgba(254, 245, 240, 0.8) !important;
}

.down-tree ::v-deep .el-tree-node.is-expanded > .el-tree-node__children {
  display: inline;
}

.down-tree {
  height: 100%;
}

.demo-pagination-block {
  float: right;
}

.custom-dialog {
  position: fixed;
  top: 10em;
  left: 50%;
  width: 20%;
  /* 其他样式... */
}

.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.labs {
  margin-bottom: 0px;
}

.lab {
  background-color: rgba(247, 247, 247, 0.903);
  text-align: center;
  margin-bottom: 0px;
  text-align: right;
}
.scrollbar-flex-content {
  width: 500px;
  margin-top: 5px;
  display: flex;
}
.scrollbar-demo-item {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  text-align: center;
}
.scr {
  height: 40px;
  background-color: rgba(247, 247, 247, 0.903);
}
.custom-collapse-title {
  font-weight: bold;
  color: #333; /* 加重的颜色 */
}
</style>
